Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test corrade_add_resource() with Unicode filenames #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/ci/appveyor-cache-reset.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Increase this number every time you want to reset AppVeyor cache.
# http://help.appveyor.com/discussions/questions/1310-delete-cache
0
1
4 changes: 3 additions & 1 deletion package/ci/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ environment:
install:
# Ninja. `cinst ninja` started 503ing in late November 2019 and wasn't really
# reliable before either. So install by hand, as that's reliable always.
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\ninja-win.zip appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip
# Version 1.11 needed to make UTF-8 work with corrade_add_resource():
# https://github.com/ninja-build/ninja/pull/1915
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\ninja-win.zip appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.11.0/ninja-win.zip
- 7z x ninja-win.zip -oC:/tools/ninja

- set PATH=C:/tools/ninja;%PATH%
Expand Down
4 changes: 3 additions & 1 deletion src/Corrade/Utility/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,20 @@ corrade_add_test(UtilityUnicodeTest UnicodeTest.cpp LIBRARIES CorradeTestSuiteTe
corrade_add_resource(ResourceTestData ResourceTestFiles/resources.conf)
corrade_add_resource(ResourceTestEmptyFileData ResourceTestFiles/resources-empty-file.conf)
corrade_add_resource(ResourceTestNothingData ResourceTestFiles/resources-nothing.conf)
corrade_add_resource(ResourceTestUtf8Data ResourceTestFiles/hýždě.conf)
corrade_add_resource(ResourceTestSpacesData ResourceTestFiles/resources-spaces.conf)
corrade_add_resource(ResourceTestNullTerminatedAlignedData ResourceTestFiles/resources-null-terminated-aligned.conf)
corrade_add_resource(ResourceTestNullTerminatedLastFileData ResourceTestFiles/resources-null-terminated-last-file.conf)
corrade_add_resource(ResourceTestAlignmentLargerThanDataSizeData ResourceTestFiles/resources-alignment-larger-than-data-size.conf)
corrade_add_resource(ResourceTestSingleData ResourceTestFiles/consequence.bin SINGLE)
corrade_add_resource(ResourceTestSingleEmptyData ResourceTestFiles/empty.bin SINGLE)

corrade_add_test(UtilityResourceTest
ResourceTest.cpp
${ResourceTestData}
${ResourceTestEmptyFileData}
${ResourceTestNothingData}
${ResourceTestUtf8Data}
${ResourceTestSpacesData}
${ResourceTestNullTerminatedAlignedData}
${ResourceTestNullTerminatedLastFileData}
Expand All @@ -346,7 +349,6 @@ corrade_add_test(UtilityResourceTest
ResourceTestFiles/consequence2.txt
ResourceTestFiles/empty.bin
ResourceTestFiles/hýždě.bin
ResourceTestFiles/hýždě.conf
ResourceTestFiles/predisposition.bin
# Referenced from resources-overriden.conf
ResourceTestFiles/predisposition2.txt
Expand Down
10 changes: 10 additions & 0 deletions src/Corrade/Utility/Test/ResourceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct ResourceTest: TestSuite::Tester {
void getEmptyFileRaw();
void getEmptyFileString();
void getNonexistentFile();
void getUtf8Filename();
void filenameWithSpaces();

void nullTerminatedAligned();
Expand Down Expand Up @@ -108,6 +109,7 @@ ResourceTest::ResourceTest() {
&ResourceTest::getEmptyFileRaw,
&ResourceTest::getEmptyFileString,
&ResourceTest::getNonexistentFile,
&ResourceTest::getUtf8Filename,
&ResourceTest::filenameWithSpaces,

&ResourceTest::nullTerminatedAligned,
Expand Down Expand Up @@ -367,6 +369,14 @@ void ResourceTest::getNonexistentFile() {
"Utility::Resource::get(): file 'nonexistentFile' was not found in group 'test'\n");
}

void ResourceTest::getUtf8Filename() {
Resource rs{"unicode"};

CORRADE_COMPARE_AS(rs.getString("hýždě.bin"),
Path::join(RESOURCE_TEST_DIR, "hýždě.bin"),
TestSuite::Compare::StringToFile);
}

void ResourceTest::filenameWithSpaces() {
Resource rs{"spaces"};

Expand Down