Skip to content

Commit

Permalink
{test} Fix tests related to UTF-8 in file names (#155)
Browse files Browse the repository at this point in the history
Fixes #136 (thanks Jiri!)
Related to #26 and #69
  • Loading branch information
asmaloney authored Oct 31, 2022
1 parent 8903993 commit d196939
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ if ( E57_VISIBILITY_HIDDEN )
set_target_properties( testE57 PROPERTIES CXX_VISIBILITY_PRESET hidden)
endif()

target_compile_options( testE57
PUBLIC
# add switches to MSVC for UTF-8 handling in our test files
$<$<C_COMPILER_ID:MSVC>:/utf-8>
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
)

# ccache
# https://crascit.com/2016/04/09/using-ccache-with-cmake/
find_program( CCACHE_PROGRAM ccache )
Expand Down
15 changes: 5 additions & 10 deletions test/src/test_SimpleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,16 @@ TEST( SimpleReaderData, DoNotCheckCRC )
}

// https://github.com/asmaloney/libE57Format/issues/26
// File name UTF-8 encoded to avoid editor issues.
TEST( SimpleReaderData, ChineseFileName )
{
E57_ASSERT_NO_THROW(
e57::Reader( TestData::Path() + "/self/\xe6\xb5\x8b\xe8\xaf\x95\xe7\x82\xb9\xe4\xba\x91.e57", {} ) );
E57_ASSERT_NO_THROW( e57::Reader( TestData::Path() + "/self/测试点云.e57", {} ) );
}

// https://github.com/asmaloney/libE57Format/issues/69
// File name UTF-8 encoded to avoid editor issues.
// No idea why this fails on Linux and Windows with "No such file or directory".
// TEST( SimpleReaderData, UmlautFileName )
//{
// E57_ASSERT_NO_THROW(
// e57::Reader( TestData::Path() + "/self/test filename \x61\xcc\x88\x6f\xcc\x88\x75\xcc\x88.e57", {} ) );
//}
TEST( SimpleReaderData, UmlautFileName )
{
E57_ASSERT_NO_THROW( e57::Reader( TestData::Path() + "/self/test filename äöü.e57", {} ) );
}

TEST( SimpleReaderData, ColouredCubeFloat )
{
Expand Down
6 changes: 2 additions & 4 deletions test/src/test_SimpleWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,23 +381,21 @@ TEST( SimpleWriter, MultipleScans )
}

// https://github.com/asmaloney/libE57Format/issues/26
// File name UTF-8 encoded to avoid editor issues.
TEST( SimpleWriter, ChineseFileName )
{
e57::WriterOptions options;
options.guid = "Chinese File Name File GUID";

E57_ASSERT_NO_THROW( e57::Writer writer( "./\xe6\xb5\x8b\xe8\xaf\x95\xe7\x82\xb9\xe4\xba\x91.e57", options ) );
E57_ASSERT_NO_THROW( e57::Writer writer( "./测试点云.e57", options ) );
}

// https://github.com/asmaloney/libE57Format/issues/69
// File name UTF-8 encoded to avoid editor issues.
TEST( SimpleWriter, WriteUmlautFileName )
{
e57::WriterOptions options;
options.guid = "Umlaut File Name File GUID";

E57_ASSERT_NO_THROW( e57::Writer writer( "./test filename \x61\xcc\x88\x6f\xcc\x88\x75\xcc\x88.e57", options ) );
E57_ASSERT_NO_THROW( e57::Writer writer( "./test filename äöü.e57", options ) );
}

TEST( SimpleWriter, CartesianPoints )
Expand Down

0 comments on commit d196939

Please sign in to comment.