From d196939a431ab3424e907f5ec97b551ef26ac843 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Mon, 31 Oct 2022 15:06:48 -0400 Subject: [PATCH] {test} Fix tests related to UTF-8 in file names (#155) Fixes #136 (thanks Jiri!) Related to #26 and #69 --- test/CMakeLists.txt | 7 +++++++ test/src/test_SimpleReader.cpp | 15 +++++---------- test/src/test_SimpleWriter.cpp | 6 ++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7939be4..80b2f7c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 + $<$:/utf-8> + $<$:/utf-8> +) + # ccache # https://crascit.com/2016/04/09/using-ccache-with-cmake/ find_program( CCACHE_PROGRAM ccache ) diff --git a/test/src/test_SimpleReader.cpp b/test/src/test_SimpleReader.cpp index 29cfb13..4f3511a 100644 --- a/test/src/test_SimpleReader.cpp +++ b/test/src/test_SimpleReader.cpp @@ -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 ) { diff --git a/test/src/test_SimpleWriter.cpp b/test/src/test_SimpleWriter.cpp index a7afc12..a44dff6 100644 --- a/test/src/test_SimpleWriter.cpp +++ b/test/src/test_SimpleWriter.cpp @@ -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 )