Skip to content

Commit

Permalink
catch2
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Mar 28, 2024
1 parent 999288f commit cd461a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if(NOT libmcfp_FOUND)
GIT_TAG v1.2.4
)

FetchContent_MakeAvailable(libmcfp)
FetchContent_MakeAvailable(libmcfp)
endif()

include(VersionString)
Expand Down Expand Up @@ -101,8 +101,8 @@ if(BUILD_TESTING)
GIT_TAG v3.5.2 # or a later release
)

FetchContent_MakeAvailable(Catch2)
endif()
FetchContent_MakeAvailable(Catch2)
endif()

file(GLOB UNIT_TEST_RSRC LIST_DIRECTORIES true ${PROJECT_SOURCE_DIR}/rsrc/*)

Expand All @@ -112,7 +112,7 @@ endif()
)

add_executable(mrc-unit-test ${PROJECT_SOURCE_DIR}/src/mrc-unit-test.cpp ${CMAKE_BINARY_DIR}/mrc-unit-test-rsrc.obj)
target_link_libraries(mrc-unit-test Catch2::Catch2)
target_link_libraries(mrc-unit-test Catch2::Catch2WithMain)

add_test(NAME unit-test COMMAND $<TARGET_FILE:mrc-unit-test> WORKING_DIRECTORY .)
endif()
Expand Down
26 changes: 13 additions & 13 deletions src/mrc-unit-test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>

#include "mrsrc.h"

Expand All @@ -18,7 +18,8 @@ TEST_CASE("test_1", "test_1")
REQUIRE(r1.size() == 50);

int r = std::memcmp(r1.data(), R"(This is the first line
And this is the second line)", r1.size());
And this is the second line)",
r1.size());

REQUIRE(r == 0);
}
Expand All @@ -31,15 +32,15 @@ TEST_CASE("test_2", "test_2")

REQUIRE(r2.data() != nullptr);
REQUIRE(r2.size() == 102);
/*
const char16_t* t = u"\xfeffThis is the first line\
And this is the second line";
// t[0] = 0xfeff;
/*
const char16_t* t = u"\xfeffThis is the first line\
And this is the second line";
// t[0] = 0xfeff;
int r = std::memcmp(r2.data(), (char*)t, r2.size());
int r = std::memcmp(r2.data(), (char*)t, r2.size());
REQUIRE(r == 0);
*/
REQUIRE(r == 0);
*/
}

TEST_CASE("test_3", "test_3")
Expand Down Expand Up @@ -74,16 +75,16 @@ TEST_CASE("test_10", "test_10")
REQUIRE(std::distance(r0.begin(), r0.end()) == 3);

std::set<std::string> found;
for (auto& r1: r0)
for (auto &r1 : r0)
found.insert(r1.name());

std::set<std::string> kTest{"resource-1.txt", "resource-2.txt", "subdir"};
std::set<std::string> kTest{ "resource-1.txt", "resource-2.txt", "subdir" };

REQUIRE(found == kTest);

if (found != kTest)
{
for (auto& f: found)
for (auto &f : found)
std::cout << f << std::endl;
}
}
Expand Down Expand Up @@ -132,4 +133,3 @@ TEST_CASE("test_14", "test_14")
REQUIRE((bool)ri == false);
REQUIRE(ri.bad() == true);
}

0 comments on commit cd461a0

Please sign in to comment.