diff --git a/cmake/FindCatch2.cmake b/cmake/FindCatch2.cmake index d51a57c..96cd4cb 100644 --- a/cmake/FindCatch2.cmake +++ b/cmake/FindCatch2.cmake @@ -1,6 +1,6 @@ set(Catch2_FOUND TRUE) -set(CATCH2_VERSION "v2.13.4") +set(CATCH2_VERSION "v2.13.7") set(CATCH2_INCLUDEDIR "${CMAKE_BINARY_DIR}/catch-${CATCH2_VERSION}") list(APPEND CMAKE_MODULE_PATH "${CATCH2_INCLUDEDIR}") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b98c714..7771628 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,13 +4,12 @@ find_package(Catch2 REQUIRED) include(CTest) include(Catch) -add_executable(${PROJECT_NAME} test.cpp link_test.cpp) +add_executable(${PROJECT_NAME} main.cpp test.cpp link_test.cpp) target_include_directories(moFileReaderTest PRIVATE ${CMAKE_SOURCE_DIR}/include) target_link_libraries(${PROJECT_NAME} PRIVATE Catch2::Catch2) catch_discover_tests(${PROJECT_NAME}) add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test.mo $/test.mo - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test.mo ${CMAKE_CURRENT_BINARY_DIR}/test.mo + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/languages/nl.mo $/languages/nl.mo ) diff --git a/test/compile_mo.sh b/test/compile_mo.sh index 64bf65c..5c6652e 100644 --- a/test/compile_mo.sh +++ b/test/compile_mo.sh @@ -1,2 +1,2 @@ #!/bin/sh -msgfmt -o test.mo test.po \ No newline at end of file +msgfmt -o languages/nl.mo languages/nl.po \ No newline at end of file diff --git a/test/test.mo b/test/languages/nl.mo similarity index 100% rename from test/test.mo rename to test/languages/nl.mo diff --git a/test/test.po b/test/languages/nl.po similarity index 100% rename from test/test.po rename to test/languages/nl.po diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000..063e878 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,2 @@ +#define CATCH_CONFIG_MAIN +#include "catch.hpp" \ No newline at end of file diff --git a/test/test.cpp b/test/test.cpp index 72b5526..376f734 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,17 +1,17 @@ -#define CATCH_CONFIG_MAIN - #include "catch.hpp" #include "moFileReader.hpp" using namespace moFileLib; +#define MO_TEST_FILE "languages/nl.mo" + #define _L(str) moFR.Lookup(str) #define _LC(ctx, str) moFR.LookupWithContext(ctx, str) TEST_CASE("Load mo-file", "[ReadFile]") { moFileReader moFR; - CHECK(moFR.ReadFile("test.mo") == moFileReader::EC_SUCCESS); + CHECK(moFR.ReadFile(MO_TEST_FILE) == moFileReader::EC_SUCCESS); } TEST_CASE("Load not existing mo-file", "[ReadFile-fail]") @@ -23,14 +23,14 @@ TEST_CASE("Load not existing mo-file", "[ReadFile-fail]") TEST_CASE("Count number of strings", "[Count]") { moFileReader moFR; - moFR.ReadFile("test.mo"); + moFR.ReadFile(MO_TEST_FILE); CHECK(7 == moFR.GetNumStrings()); } TEST_CASE("Empties the Lookup-Table", "[Count]") { moFileReader moFR; - moFR.ReadFile("test.mo"); + moFR.ReadFile(MO_TEST_FILE); CHECK("Text Nederlands Een" == moFR.Lookup("String English One")); CHECK(7 == moFR.GetNumStrings()); moFR.ClearTable(); @@ -41,7 +41,7 @@ TEST_CASE("Empties the Lookup-Table", "[Count]") TEST_CASE("Lookup string", "[Lookup]") { moFileReader moFR; - moFR.ReadFile("test.mo"); + moFR.ReadFile(MO_TEST_FILE); /* This is the first comment. */ CHECK("Text Nederlands Een" == _L("String English One")); /* This is the second comment. */ @@ -53,7 +53,7 @@ TEST_CASE("Lookup string", "[Lookup]") TEST_CASE("Lookup string with context", "[LookupWithContext]") { moFileReader moFR; - moFR.ReadFile("test.mo"); + moFR.ReadFile(MO_TEST_FILE); /* This is the first comment. */ CHECK("Text Nederlands Een" == _LC("TEST|String|1", "String English")); /* This is the second comment. */ @@ -65,7 +65,7 @@ TEST_CASE("Lookup string with context", "[LookupWithContext]") TEST_CASE("Lookup not existing strings", "[Lookup-fail]") { moFileReader moFR; - moFR.ReadFile("test.mo"); + moFR.ReadFile(MO_TEST_FILE); CHECK("No match" == moFR.Lookup("No match")); CHECK("Can't touch this" == moFR.Lookup("Can't touch this")); } @@ -73,7 +73,7 @@ TEST_CASE("Lookup not existing strings", "[Lookup-fail]") TEST_CASE("Lookup not existing strings with context", "[LookupWithContext-fail]") { moFileReader moFR; - moFR.ReadFile("test.mo"); + moFR.ReadFile(MO_TEST_FILE); CHECK("String English" == _LC("Nope", "String English")); CHECK("Not this one" == _LC("TEST|String|1", "Not this one")); } \ No newline at end of file