diff --git a/src/Corrade/Utility/Test/CMakeLists.txt b/src/Corrade/Utility/Test/CMakeLists.txt index e823fdf08..1ea0bebf1 100644 --- a/src/Corrade/Utility/Test/CMakeLists.txt +++ b/src/Corrade/Utility/Test/CMakeLists.txt @@ -163,11 +163,18 @@ corrade_add_test(UtilityUnicodeTest UnicodeTest.cpp LIBRARIES CorradeUtilityTest corrade_add_resource(ResourceTestData ResourceTestFiles/resources.conf) corrade_add_resource(ResourceTestEmptyFileData ResourceTestFiles/resources-empty-file.conf) corrade_add_resource(ResourceTestNothingData ResourceTestFiles/resources-nothing.conf) + +# CMake < 3.1 can't handle UTF-8 in file(STRINGS) +if(NOT CMAKE_VERSION VERSION_LESS 3.1) + corrade_add_resource(ResourceTestUtf8Data ResourceTestFiles/hýždě.conf) +endif() + corrade_add_test(UtilityResourceTest ResourceTest.cpp ${ResourceTestData} ${ResourceTestEmptyFileData} ${ResourceTestNothingData} + ${ResourceTestUtf8Data} LIBRARIES CorradeUtilityTestLib FILES ResourceTestFiles/compiled.cpp @@ -195,6 +202,11 @@ corrade_add_test(UtilityResourceTest ResourceTestFiles/resources-overriden-nonexistent-file.conf) target_include_directories(UtilityResourceTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +# CMake < 3.1 can't handle UTF-8 in file(STRINGS), disable relevant test case +if(CMAKE_VERSION VERSION_LESS 3.1) + target_compile_definitions(UtilityResourceTest PRIVATE "RESOURCETETST_NO_UNICODE") +endif() + # Static lib resource test add_library(ResourceTestDataLib STATIC ${ResourceTestData}) target_link_libraries(ResourceTestDataLib CorradeUtility) diff --git a/src/Corrade/Utility/Test/ResourceTest.cpp b/src/Corrade/Utility/Test/ResourceTest.cpp index 3311f909a..563955ebb 100644 --- a/src/Corrade/Utility/Test/ResourceTest.cpp +++ b/src/Corrade/Utility/Test/ResourceTest.cpp @@ -56,6 +56,7 @@ struct ResourceTest: TestSuite::Tester { void getEmptyFile(); void getNonexistent(); void getNothing(); + void getUtf8Filename(); void overrideGroup(); void overrideGroupFallback(); @@ -83,6 +84,7 @@ ResourceTest::ResourceTest() { &ResourceTest::getEmptyFile, &ResourceTest::getNonexistent, &ResourceTest::getNothing, + &ResourceTest::getUtf8Filename, &ResourceTest::overrideGroup, &ResourceTest::overrideGroupFallback, @@ -239,6 +241,17 @@ void ResourceTest::getNothing() { CORRADE_VERIFY(r.get("nonexistentFile").empty()); } +void ResourceTest::getUtf8Filename() { + #ifdef RESOURCETETST_NO_UNICODE + CORRADE_SKIP("CMake < 3.1 used, can't test compilation of resources with UTF-8 filenames."); + #else + Resource r("unicode"); + CORRADE_COMPARE_AS(r.get("hýždě.bin"), + Directory::join(RESOURCE_TEST_DIR, "hýždě.bin"), + TestSuite::Compare::StringToFile); + #endif +} + void ResourceTest::overrideGroup() { std::ostringstream out; Debug redirectDebug{&out};