From 9fdc9a579a0a4975b40d13161bf337afb77b068a Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 4 Dec 2024 09:51:02 +0000 Subject: [PATCH 01/66] Add include path for core/visibility to cmake --- src/common/util/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 9d3d83cb54c804..ded80f54dbfa9d 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -77,7 +77,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::p if (WIN32) target_link_libraries(${TARGET_NAME} PRIVATE Shlwapi) endif() -target_include_directories(${TARGET_NAME} PUBLIC $) +target_include_directories(${TARGET_NAME} PUBLIC $ + PRIVATE "${OpenVINO_SOURCE_DIR}/src/core/include") ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} From 546897e8227686421bd556d4761a0d60fb884bc1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 4 Dec 2024 09:52:54 +0000 Subject: [PATCH 02/66] std::fs::path alias --- .../util/include/openvino/util/file_path.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/common/util/include/openvino/util/file_path.hpp diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp new file mode 100644 index 00000000000000..30eb92dca8721d --- /dev/null +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "openvino/util/filesystem.hpp" +namespace ov { +namespace util { + +namespace fs = std_fs; +using Path = fs::path; + +} // namespace util +} // namespace ov From 7d0f218e80bfd4c8813c8b2d2efb0c53ee8ee26c Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 5 Dec 2024 10:09:16 +0000 Subject: [PATCH 03/66] improve includes and Path alias definition --- src/common/util/include/openvino/util/file_path.hpp | 7 +++++-- src/common/util/include/openvino/util/filesystem.hpp | 12 +++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 30eb92dca8721d..4fb89affb2324f 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -10,8 +10,11 @@ namespace ov { namespace util { -namespace fs = std_fs; -using Path = fs::path; +#if defined(OPENVINO_HAS_FILESYSTEM) +using Path = std::filesystem::path; +#elif defined(OPENVINO_HAS_EXP_FILESYSTEM) +using Path = std::experimental::filesystem::path; +#endif } // namespace util } // namespace ov diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index ede97cabb0ba24..b9292ecd254617 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -20,12 +20,10 @@ # endif #endif -#if !defined(OPENVINO_HAS_FILESYSTEM) && !defined(OPENVINO_HAS_EXP_FILESYSTEM) -# error "Neither #include nor #include is available." -#elif defined(OPENVINO_HAS_FILESYSTEM) -# include -namespace std_fs = std::filesystem; +#if defined(OPENVINO_HAS_FILESYSTEM) +#include #elif defined(OPENVINO_HAS_EXP_FILESYSTEM) -# include -namespace std_fs = std::experimental::filesystem; +#include +#else +#error "Neither #include nor #include is available." #endif From d46f60e6ffc0756f4bae65105c1da15fc04369c1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 09:38:14 +0000 Subject: [PATCH 04/66] add tests --- src/core/tests/file_util.cpp | 226 +++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index f83c8dd55b5a2d..aafabf29235201 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -167,3 +167,229 @@ TEST_F(TrimFileTest, relatice_path_to_source_forward_slash_always_supported) { auto str_ptr = ov::util::trim_file_name(file_path.c_str()); EXPECT_EQ(exp_path, str_ptr); } + +TEST(file_util, path_cast) { + // from char to char + EXPECT_STREQ("", ov::util::Path("").string().c_str()); + EXPECT_STREQ("file.txt", ov::util::Path("file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path("./local/file.txt").string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path("~/local/file.txt").string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_string().c_str()); + + // from char8_t to char + EXPECT_STREQ("", ov::util::Path(u8"").string().c_str()); + EXPECT_STREQ("file.txt", ov::util::Path(u8"file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(u8"./local/file.txt").string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(u8"~/local/file.txt").string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_string().c_str()); + + // from char16_t to char + EXPECT_STREQ("", ov::util::Path(u"").string().c_str()); + EXPECT_STREQ("file.txt", ov::util::Path(u"file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(u"./local/file.txt").string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(u"~/local/file.txt").string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_string().c_str()); + + // from char32_t to char + EXPECT_STREQ("", ov::util::Path(U"").string().c_str()); + EXPECT_STREQ("file.txt", ov::util::Path(U"file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(U"./local/file.txt").string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(U"~/local/file.txt").string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_string().c_str()); + + + // from char to wchar_t + EXPECT_STREQ(L"", ov::util::Path("").wstring().c_str()); + EXPECT_STREQ(L"file.txt", ov::util::Path("file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path("./local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path("~/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").wstring().c_str()); + EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_wstring().c_str()); + + // from char8_t to wchar_t + EXPECT_STREQ(L"", ov::util::Path(u8"").wstring().c_str()); + EXPECT_STREQ(L"file.txt", ov::util::Path(u8"file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u8"./local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_wstring().c_str()); + + // from char16_t to wchar_t + EXPECT_STREQ(L"", ov::util::Path(u"").wstring().c_str()); + EXPECT_STREQ(L"file.txt", ov::util::Path(u"file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u"./local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u"~/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_wstring().c_str()); + + // from char32_t to wchar_t + EXPECT_STREQ(L"", ov::util::Path(U"").wstring().c_str()); + EXPECT_STREQ(L"file.txt", ov::util::Path(U"file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(U"./local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(U"~/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_wstring().c_str()); + + + // from char to u16string + EXPECT_EQ(u"", ov::util::Path("").u16string()); + EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_u16string()); + + // from char8_t to u16string + EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); + EXPECT_EQ(u"file.txt", ov::util::Path(u8"file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(u8"./local/file.txt").u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_u16string()); + + // from char16_t to u16string + EXPECT_EQ(u"", ov::util::Path(u"").u16string()); + EXPECT_EQ(u"file.txt", ov::util::Path(u"file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(u"./local/file.txt").u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u"~/local/file.txt").u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_u16string()); + + // from char32_t to u16string + EXPECT_EQ(u"", ov::util::Path(U"").u16string()); + EXPECT_EQ(u"file.txt", ov::util::Path(U"file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(U"./local/file.txt").u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_u16string()); + + + // from char to u32string + EXPECT_EQ(U"", ov::util::Path("").u32string()); + EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); + EXPECT_EQ(U"./local/file.txt", ov::util::Path("./local/file.txt").u32string()); + EXPECT_EQ(U"~/local/file.txt", ov::util::Path("~/local/file.txt").u32string()); + EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u32string()); + EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_u32string()); + + // from char8_t to u32string + EXPECT_EQ(U"", ov::util::Path(u8"").u32string()); + EXPECT_EQ(U"file.txt", ov::util::Path(u8"file.txt").u32string()); + EXPECT_EQ(U"./local/file.txt", ov::util::Path(u8"./local/file.txt").u32string()); + EXPECT_EQ(U"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").u32string()); + EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u32string()); + EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_u32string()); + + // from char16_t to u32string + EXPECT_EQ(U"", ov::util::Path(u"").u32string()); + EXPECT_EQ(U"file.txt", ov::util::Path(u"file.txt").u32string()); + EXPECT_EQ(U"./local/file.txt", ov::util::Path(u"./local/file.txt").u32string()); + EXPECT_EQ(U"~/local/file.txt", ov::util::Path(u"~/local/file.txt").u32string()); + EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u32string()); + EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_u32string()); + + // from char32_t to u32string + EXPECT_EQ(U"", ov::util::Path(U"").u32string()); + EXPECT_EQ(U"file.txt", ov::util::Path(U"file.txt").u32string()); + EXPECT_EQ(U"./local/file.txt", ov::util::Path(U"./local/file.txt").u32string()); + EXPECT_EQ(U"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u32string()); + EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u32string()); + EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_u32string()); + + + // from char, char8_t, char16_t, char32_t to u16string + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + + // from char, char8_t, char16_t, char32_t to u32string + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + +#if ( \ + (defined(__GNUC__) && (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) || \ + (defined(__clang__) && __clang_major__ >= 17) \ +) +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 +// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath + + // from wchar_t to char + EXPECT_STREQ("", ov::util::Path(L"").string().c_str()); + EXPECT_STREQ("file.txt", ov::util::Path(L"file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_string().c_str()); + + // from wchar_t to wchar_t + EXPECT_STREQ(L"", ov::util::Path(L"").wstring().c_str()); + EXPECT_STREQ(L"file.txt", ov::util::Path(L"file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(L"./local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(L"~/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_wstring().c_str()); + + // from wchar_t to char8_t + EXPECT_STREQ("", ov::util::Path(L"").u8string().c_str()); + EXPECT_STREQ("file.txt", ov::util::Path(L"file.txt").u8string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").u8string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").u8string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u8string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u8string().c_str()); + EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u8string().c_str()); + + // from wchar_t to char16_t + EXPECT_EQ(u"", ov::util::Path(L"").u16string()); + EXPECT_EQ(u"file.txt", ov::util::Path(L"file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(L"./local/file.txt").u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u16string()); + + // from wchar_t to char32_t + EXPECT_EQ(U"", ov::util::Path(L"").u32string()); + EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); + EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); + EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); + EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u32string()); + + // from char, char8_t, char16_t, char32_t to wchar_t + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); +#endif +} From 86f602e10cd5de77c347d7bedbda23259c40b9b4 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 12:19:27 +0000 Subject: [PATCH 05/66] code foramt --- .../util/include/openvino/util/filesystem.hpp | 6 +-- src/core/tests/file_util.cpp | 43 +++++++++++-------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index b9292ecd254617..a4f802e063a406 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -21,9 +21,9 @@ #endif #if defined(OPENVINO_HAS_FILESYSTEM) -#include +# include #elif defined(OPENVINO_HAS_EXP_FILESYSTEM) -#include +# include #else -#error "Neither #include nor #include is available." +# error "Neither #include nor #include is available." #endif diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index aafabf29235201..245b2ad132ac09 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -11,6 +11,8 @@ #include #include +#include "openvino/util/file_path.hpp" + using namespace std; using namespace ov; @@ -185,7 +187,8 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(u8"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(u8"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_string().c_str()); // from char16_t to char @@ -194,7 +197,8 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(u"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(u"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_string().c_str()); // from char32_t to char @@ -203,10 +207,10 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(U"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(U"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_string().c_str()); - // from char to wchar_t EXPECT_STREQ(L"", ov::util::Path("").wstring().c_str()); EXPECT_STREQ(L"file.txt", ov::util::Path("file.txt").wstring().c_str()); @@ -240,7 +244,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_wstring().c_str()); - // from char to u16string EXPECT_EQ(u"", ov::util::Path("").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); @@ -281,7 +284,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_u16string()); - // from char to u32string EXPECT_EQ(U"", ov::util::Path("").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); @@ -322,7 +324,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_u32string()); - // from char, char8_t, char16_t, char32_t to u16string EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); @@ -335,12 +336,10 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); -#if ( \ - (defined(__GNUC__) && (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) || \ - (defined(__clang__) && __clang_major__ >= 17) \ -) -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 -// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath +#if ((defined(__GNUC__) && (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) || \ + (defined(__clang__) && __clang_major__ >= 17)) + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 + // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath // from wchar_t to char EXPECT_STREQ("", ov::util::Path(L"").string().c_str()); @@ -348,7 +347,8 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_string().c_str()); // from wchar_t to wchar_t @@ -365,7 +365,8 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").u8string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").u8string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u8string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u8string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u8string().c_str()); EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u8string().c_str()); // from wchar_t to char16_t @@ -387,9 +388,13 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u32string()); // from char, char8_t, char16_t, char32_t to wchar_t - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); #endif } From 3770a18a67128b3fb17ec2d4c0b4b60199faa32c Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 12:35:48 +0000 Subject: [PATCH 06/66] revert cmake, move OPENVINO_CPP_VER from visability to util --- src/common/util/CMakeLists.txt | 3 +- .../util/include/openvino/util/filesystem.hpp | 2 +- .../util/include/openvino/util/util.hpp | 28 ++++++++++++ src/core/include/openvino/core/visibility.hpp | 44 ++----------------- 4 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index ded80f54dbfa9d..9d3d83cb54c804 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -77,8 +77,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::p if (WIN32) target_link_libraries(${TARGET_NAME} PRIVATE Shlwapi) endif() -target_include_directories(${TARGET_NAME} PUBLIC $ - PRIVATE "${OpenVINO_SOURCE_DIR}/src/core/include") +target_include_directories(${TARGET_NAME} PUBLIC $) ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index a4f802e063a406..7907702be7ce1e 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -4,7 +4,7 @@ #pragma once -#include "openvino/core/visibility.hpp" +#include "util.hpp" #if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_11) # define OPENVINO_HAS_EXP_FILESYSTEM diff --git a/src/common/util/include/openvino/util/util.hpp b/src/common/util/include/openvino/util/util.hpp index 3d696f7e32e858..2946a4c0d2bdce 100644 --- a/src/common/util/include/openvino/util/util.hpp +++ b/src/common/util/include/openvino/util/util.hpp @@ -24,3 +24,31 @@ # define OPENVINO_DISABLE_WARNING_MSVC_BEGIN(id) # define OPENVINO_DISABLE_WARNING_MSVC_END(id) #endif + +#if !(defined(_MSC_VER) && __cplusplus == 199711L) +# if __cplusplus >= 201103L +# define OPENVINO_CPP_VER_11 +# if __cplusplus >= 201402L +# define OPENVINO_CPP_VER_14 +# if __cplusplus >= 201703L +# define OPENVINO_CPP_VER_17 +# if __cplusplus >= 202002L +# define OPENVINO_CPP_VER_20 +# endif +# endif +# endif +# endif +#elif defined(_MSC_VER) && __cplusplus == 199711L +# if _MSVC_LANG >= 201103L +# define OPENVINO_CPP_VER_11 +# if _MSVC_LANG >= 201402L +# define OPENVINO_CPP_VER_14 +# if _MSVC_LANG >= 201703L +# define OPENVINO_CPP_VER_17 +# if _MSVC_LANG >= 202002L +# define OPENVINO_CPP_VER_20 +# endif +# endif +# endif +# endif +#endif diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index 2dabbb42d2df07..53906e0c32dce5 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -5,6 +5,10 @@ // https://gcc.gnu.org/wiki/Visibility // Generic helper definitions for shared library support +#pragma once + +#include "openvino/util/util.hpp" + #ifndef OPENVINO_EXTERN_C # ifdef __cplusplus # define OPENVINO_EXTERN_C extern "C" @@ -21,18 +25,6 @@ # define OPENVINO_STDCALL #endif -#ifndef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# ifdef _WIN32 -# if defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__GNUC__) -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# endif -# elif defined(__clang__) -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# endif -#endif - #if defined(_WIN32) || defined(__CYGWIN__) # define OPENVINO_CORE_IMPORTS __declspec(dllimport) # define OPENVINO_CORE_EXPORTS __declspec(dllexport) @@ -77,31 +69,3 @@ #else # define OV_NO_DANGLING #endif - -#if !(defined(_MSC_VER) && __cplusplus == 199711L) -# if __cplusplus >= 201103L -# define OPENVINO_CPP_VER_11 -# if __cplusplus >= 201402L -# define OPENVINO_CPP_VER_14 -# if __cplusplus >= 201703L -# define OPENVINO_CPP_VER_17 -# if __cplusplus >= 202002L -# define OPENVINO_CPP_VER_20 -# endif -# endif -# endif -# endif -#elif defined(_MSC_VER) && __cplusplus == 199711L -# if _MSVC_LANG >= 201103L -# define OPENVINO_CPP_VER_11 -# if _MSVC_LANG >= 201402L -# define OPENVINO_CPP_VER_14 -# if _MSVC_LANG >= 201703L -# define OPENVINO_CPP_VER_17 -# if _MSVC_LANG >= 202002L -# define OPENVINO_CPP_VER_20 -# endif -# endif -# endif -# endif -#endif From e82d54b5cec29d4cbc4b83c4377a8d9b3fb4d86a Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 12:48:18 +0000 Subject: [PATCH 07/66] do not include util.hpp in visability.hpp --- src/core/include/openvino/core/visibility.hpp | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index 53906e0c32dce5..2dabbb42d2df07 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -5,10 +5,6 @@ // https://gcc.gnu.org/wiki/Visibility // Generic helper definitions for shared library support -#pragma once - -#include "openvino/util/util.hpp" - #ifndef OPENVINO_EXTERN_C # ifdef __cplusplus # define OPENVINO_EXTERN_C extern "C" @@ -25,6 +21,18 @@ # define OPENVINO_STDCALL #endif +#ifndef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# ifdef _WIN32 +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) || defined(__GNUC__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# endif +# elif defined(__clang__) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) +# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# endif +#endif + #if defined(_WIN32) || defined(__CYGWIN__) # define OPENVINO_CORE_IMPORTS __declspec(dllimport) # define OPENVINO_CORE_EXPORTS __declspec(dllexport) @@ -69,3 +77,31 @@ #else # define OV_NO_DANGLING #endif + +#if !(defined(_MSC_VER) && __cplusplus == 199711L) +# if __cplusplus >= 201103L +# define OPENVINO_CPP_VER_11 +# if __cplusplus >= 201402L +# define OPENVINO_CPP_VER_14 +# if __cplusplus >= 201703L +# define OPENVINO_CPP_VER_17 +# if __cplusplus >= 202002L +# define OPENVINO_CPP_VER_20 +# endif +# endif +# endif +# endif +#elif defined(_MSC_VER) && __cplusplus == 199711L +# if _MSVC_LANG >= 201103L +# define OPENVINO_CPP_VER_11 +# if _MSVC_LANG >= 201402L +# define OPENVINO_CPP_VER_14 +# if _MSVC_LANG >= 201703L +# define OPENVINO_CPP_VER_17 +# if _MSVC_LANG >= 202002L +# define OPENVINO_CPP_VER_20 +# endif +# endif +# endif +# endif +#endif From 1f8d806150a0b892cd3ef61ec54e4b27980411bb Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 14:04:36 +0000 Subject: [PATCH 08/66] clean cpp version defines --- .../include/openvino/util/cpp_version.hpp | 35 +++++++++++++++++++ .../util/include/openvino/util/util.hpp | 28 --------------- src/core/include/openvino/core/visibility.hpp | 28 --------------- 3 files changed, 35 insertions(+), 56 deletions(-) create mode 100644 src/common/util/include/openvino/util/cpp_version.hpp diff --git a/src/common/util/include/openvino/util/cpp_version.hpp b/src/common/util/include/openvino/util/cpp_version.hpp new file mode 100644 index 00000000000000..c0998588027c2a --- /dev/null +++ b/src/common/util/include/openvino/util/cpp_version.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +/** + * @brief Define a separate value for every version of C++ standard upto currently supported by build setup. + */ +#if !(defined(_MSC_VER) && __cplusplus == 199711L) +# if __cplusplus >= 201103L +# define OPENVINO_CPP_VER_AT_LEAST_11 +# if __cplusplus >= 201402L +# define OPENVINO_CPP_VER_AT_LEAST_14 +# if __cplusplus >= 201703L +# define OPENVINO_CPP_VER_AT_LEAST_17 +# if __cplusplus >= 202002L +# define OPENVINO_CPP_VER_AT_LEAST_20 +# endif +# endif +# endif +# endif +#elif defined(_MSC_VER) && __cplusplus == 199711L +# if _MSVC_LANG >= 201103L +# define OPENVINO_CPP_VER_AT_LEAST_11 +# if _MSVC_LANG >= 201402L +# define OPENVINO_CPP_VER_AT_LEAST_14 +# if _MSVC_LANG >= 201703L +# define OPENVINO_CPP_VER_AT_LEAST_17 +# if _MSVC_LANG >= 202002L +# define OPENVINO_CPP_VER_AT_LEAST_20 +# endif +# endif +# endif +# endif +#endif diff --git a/src/common/util/include/openvino/util/util.hpp b/src/common/util/include/openvino/util/util.hpp index 2946a4c0d2bdce..3d696f7e32e858 100644 --- a/src/common/util/include/openvino/util/util.hpp +++ b/src/common/util/include/openvino/util/util.hpp @@ -24,31 +24,3 @@ # define OPENVINO_DISABLE_WARNING_MSVC_BEGIN(id) # define OPENVINO_DISABLE_WARNING_MSVC_END(id) #endif - -#if !(defined(_MSC_VER) && __cplusplus == 199711L) -# if __cplusplus >= 201103L -# define OPENVINO_CPP_VER_11 -# if __cplusplus >= 201402L -# define OPENVINO_CPP_VER_14 -# if __cplusplus >= 201703L -# define OPENVINO_CPP_VER_17 -# if __cplusplus >= 202002L -# define OPENVINO_CPP_VER_20 -# endif -# endif -# endif -# endif -#elif defined(_MSC_VER) && __cplusplus == 199711L -# if _MSVC_LANG >= 201103L -# define OPENVINO_CPP_VER_11 -# if _MSVC_LANG >= 201402L -# define OPENVINO_CPP_VER_14 -# if _MSVC_LANG >= 201703L -# define OPENVINO_CPP_VER_17 -# if _MSVC_LANG >= 202002L -# define OPENVINO_CPP_VER_20 -# endif -# endif -# endif -# endif -#endif diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index 2dabbb42d2df07..bcce8a0736bdc1 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -77,31 +77,3 @@ #else # define OV_NO_DANGLING #endif - -#if !(defined(_MSC_VER) && __cplusplus == 199711L) -# if __cplusplus >= 201103L -# define OPENVINO_CPP_VER_11 -# if __cplusplus >= 201402L -# define OPENVINO_CPP_VER_14 -# if __cplusplus >= 201703L -# define OPENVINO_CPP_VER_17 -# if __cplusplus >= 202002L -# define OPENVINO_CPP_VER_20 -# endif -# endif -# endif -# endif -#elif defined(_MSC_VER) && __cplusplus == 199711L -# if _MSVC_LANG >= 201103L -# define OPENVINO_CPP_VER_11 -# if _MSVC_LANG >= 201402L -# define OPENVINO_CPP_VER_14 -# if _MSVC_LANG >= 201703L -# define OPENVINO_CPP_VER_17 -# if _MSVC_LANG >= 202002L -# define OPENVINO_CPP_VER_20 -# endif -# endif -# endif -# endif -#endif From 4813a39a4135acd641d1caa556d73a95cfd05f97 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 14:05:45 +0000 Subject: [PATCH 09/66] remove generic_string tests --- src/core/tests/file_util.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 245b2ad132ac09..ccd37ecb248f5a 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -179,7 +179,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").string().c_str()); EXPECT_STREQ("C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_string().c_str()); // from char8_t to char EXPECT_STREQ("", ov::util::Path(u8"").string().c_str()); @@ -189,7 +188,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_string().c_str()); // from char16_t to char EXPECT_STREQ("", ov::util::Path(u"").string().c_str()); @@ -199,7 +197,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_string().c_str()); // from char32_t to char EXPECT_STREQ("", ov::util::Path(U"").string().c_str()); @@ -209,7 +206,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_string().c_str()); // from char to wchar_t EXPECT_STREQ(L"", ov::util::Path("").wstring().c_str()); @@ -349,7 +345,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_string().c_str()); // from wchar_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(L"").wstring().c_str()); From 242e39647985537866b94607ff0e23470d2871ca Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 14:23:07 +0000 Subject: [PATCH 10/66] apply new cpp version macro --- src/common/util/include/openvino/util/filesystem.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index 7907702be7ce1e..cf48cc561de2da 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -4,16 +4,16 @@ #pragma once -#include "util.hpp" +#include "openvino/util/cpp_version.hpp" -#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_11) +#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_11) # define OPENVINO_HAS_EXP_FILESYSTEM # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM #elif defined(__has_include) -# if defined(OPENVINO_CPP_VER_17) && (__has_include()) && (!__has_include()) +# if defined(OPENVINO_CPP_VER_AT_LEAST_17) && (__has_include()) && (!__has_include()) # define OPENVINO_HAS_FILESYSTEM -# elif defined(OPENVINO_CPP_VER_11) && (__has_include()) +# elif defined(OPENVINO_CPP_VER_AT_LEAST_11) && (__has_include()) # define OPENVINO_HAS_EXP_FILESYSTEM # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM From 2f696f530e6315ec47eb45c9c65c875431c6ed26 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 15:01:43 +0000 Subject: [PATCH 11/66] remove all generic_*string tests --- src/core/tests/file_util.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index ccd37ecb248f5a..12e0b1b1382081 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -214,7 +214,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"~/local/file.txt", ov::util::Path("~/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").wstring().c_str()); - EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_wstring().c_str()); // from char8_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(u8"").wstring().c_str()); @@ -222,7 +221,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u8"./local/file.txt").wstring().c_str()); EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_wstring().c_str()); // from char16_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(u"").wstring().c_str()); @@ -230,7 +228,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u"./local/file.txt").wstring().c_str()); EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u"~/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_wstring().c_str()); // from char32_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(U"").wstring().c_str()); @@ -238,7 +235,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"./local/file.txt", ov::util::Path(U"./local/file.txt").wstring().c_str()); EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(U"~/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_wstring().c_str()); // from char to u16string EXPECT_EQ(u"", ov::util::Path("").u16string()); @@ -248,7 +244,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_u16string()); // from char8_t to u16string EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); @@ -258,7 +253,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_u16string()); // from char16_t to u16string EXPECT_EQ(u"", ov::util::Path(u"").u16string()); @@ -268,7 +262,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_u16string()); // from char32_t to u16string EXPECT_EQ(u"", ov::util::Path(U"").u16string()); @@ -278,7 +271,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_u16string()); // from char to u32string EXPECT_EQ(U"", ov::util::Path("").u32string()); @@ -288,7 +280,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path("///a/////b////c///file.txt").generic_u32string()); // from char8_t to u32string EXPECT_EQ(U"", ov::util::Path(u8"").u32string()); @@ -298,7 +289,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(u8"///a/////b////c///file.txt").generic_u32string()); // from char16_t to u32string EXPECT_EQ(U"", ov::util::Path(u"").u32string()); @@ -308,7 +298,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(u"///a/////b////c///file.txt").generic_u32string()); // from char32_t to u32string EXPECT_EQ(U"", ov::util::Path(U"").u32string()); @@ -318,7 +307,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(U"///a/////b////c///file.txt").generic_u32string()); // from char, char8_t, char16_t, char32_t to u16string EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); @@ -352,7 +340,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"./local/file.txt", ov::util::Path(L"./local/file.txt").wstring().c_str()); EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(L"~/local/file.txt").wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_wstring().c_str()); // from wchar_t to char8_t EXPECT_STREQ("", ov::util::Path(L"").u8string().c_str()); @@ -362,7 +349,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u8string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u8string().c_str()); - EXPECT_STREQ("/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u8string().c_str()); // from wchar_t to char16_t EXPECT_EQ(u"", ov::util::Path(L"").u16string()); @@ -371,7 +357,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u16string()); // from wchar_t to char32_t EXPECT_EQ(U"", ov::util::Path(L"").u32string()); @@ -380,7 +365,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"/a/b/c/file.txt", ov::util::Path(L"///a/////b////c///file.txt").generic_u32string()); // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", From 1b2b5e32bbdcb57df46e43e02a0663dfcd056b4d Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 16:18:01 +0000 Subject: [PATCH 12/66] skip u32string cast in windows tests --- src/core/tests/file_util.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 12e0b1b1382081..7839246655b3d9 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -272,6 +272,15 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + // from char, char8_t, char16_t, char32_t to u16string + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + +#ifndef MSVC + //error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to reference a deleted function + // from char to u32string EXPECT_EQ(U"", ov::util::Path("").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); @@ -308,20 +317,16 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - // from char, char8_t, char16_t, char32_t to u16string - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - // from char, char8_t, char16_t, char32_t to u32string EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); +#endif #if ((defined(__GNUC__) && (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) || \ - (defined(__clang__) && __clang_major__ >= 17)) + (defined(__clang__) && __clang_major__ >= 17) || \ + defined(MSVC)) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath @@ -358,6 +363,8 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); +#ifndef MSVC + //error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to reference a deleted function // from wchar_t to char32_t EXPECT_EQ(U"", ov::util::Path(L"").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); @@ -365,6 +372,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); +#endif // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", From 14452c5c102a889898352f8a5f997e726018a4e1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 6 Dec 2024 16:36:08 +0000 Subject: [PATCH 13/66] format --- src/core/tests/file_util.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 7839246655b3d9..64243feae166fd 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -279,7 +279,8 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); #ifndef MSVC - //error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to reference a deleted function + // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to + // reference a deleted function // from char to u32string EXPECT_EQ(U"", ov::util::Path("").u32string()); @@ -324,9 +325,8 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); #endif -#if ((defined(__GNUC__) && (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) || \ - (defined(__clang__) && __clang_major__ >= 17) || \ - defined(MSVC)) +#if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ + !(defined(__clang__) && __clang_major__ < 17)) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath @@ -363,16 +363,17 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); -#ifndef MSVC - //error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to reference a deleted function - // from wchar_t to char32_t +# ifndef MSVC + // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to + // reference a deleted function + // from wchar_t to char32_t EXPECT_EQ(U"", ov::util::Path(L"").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); -#endif +# endif // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", From 9a788e906ec82e8082a8055560db4038e02c8bf7 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 08:51:16 +0000 Subject: [PATCH 14/66] restore visibility defines --- src/core/include/openvino/core/visibility.hpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index bcce8a0736bdc1..2dabbb42d2df07 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -77,3 +77,31 @@ #else # define OV_NO_DANGLING #endif + +#if !(defined(_MSC_VER) && __cplusplus == 199711L) +# if __cplusplus >= 201103L +# define OPENVINO_CPP_VER_11 +# if __cplusplus >= 201402L +# define OPENVINO_CPP_VER_14 +# if __cplusplus >= 201703L +# define OPENVINO_CPP_VER_17 +# if __cplusplus >= 202002L +# define OPENVINO_CPP_VER_20 +# endif +# endif +# endif +# endif +#elif defined(_MSC_VER) && __cplusplus == 199711L +# if _MSVC_LANG >= 201103L +# define OPENVINO_CPP_VER_11 +# if _MSVC_LANG >= 201402L +# define OPENVINO_CPP_VER_14 +# if _MSVC_LANG >= 201703L +# define OPENVINO_CPP_VER_17 +# if _MSVC_LANG >= 202002L +# define OPENVINO_CPP_VER_20 +# endif +# endif +# endif +# endif +#endif From dd2e22531554e2ef86279a50b76de7d2b46899d5 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 08:58:28 +0000 Subject: [PATCH 15/66] skip u32string cast in windows tests, remove nested macro check --- src/core/tests/file_util.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 64243feae166fd..6a5d8521094e4e 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -278,7 +278,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); -#ifndef MSVC +#!defined(_MSC_VER) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function @@ -363,18 +363,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); -# ifndef MSVC - // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to - // reference a deleted function - // from wchar_t to char32_t - EXPECT_EQ(U"", ov::util::Path(L"").u32string()); - EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); - EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); - EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); - EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); -# endif - // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); @@ -385,4 +373,18 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); #endif + +#if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ + !(defined(__clang__) && __clang_major__ < 17) && \ + !defined(_MSC_VER)) + // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to + // reference a deleted function + // from wchar_t to char32_t + EXPECT_EQ(U"", ov::util::Path(L"").u32string()); + EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); + EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); + EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); + EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); +# endif } From 29817d653ffb4d81a3b45b3b9bad72c70d34b92b Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 09:42:47 +0000 Subject: [PATCH 16/66] fix check --- src/core/tests/file_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 6a5d8521094e4e..169aa69c0c5399 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -278,7 +278,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); -#!defined(_MSC_VER) +#if !defined(_MSC_VER) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function From d8b6c6d29bc121486bc34a576bd1901f54563f26 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 10:08:24 +0000 Subject: [PATCH 17/66] code format --- src/core/tests/file_util.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 169aa69c0c5399..6397a764d31082 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -375,8 +375,7 @@ TEST(file_util, path_cast) { #endif #if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17) && \ - !defined(_MSC_VER)) + !(defined(__clang__) && __clang_major__ < 17) && !defined(_MSC_VER)) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function // from wchar_t to char32_t @@ -386,5 +385,5 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); -# endif +#endif } From 43ff3b69efc3289ff77fd4ebcf8bd5f41bea3ca7 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 11:37:56 +0000 Subject: [PATCH 18/66] check define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT --- src/core/tests/file_util.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 6397a764d31082..6c9f1308d584aa 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -178,7 +178,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("~/local/file.txt", ov::util::Path("~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").string().c_str()); EXPECT_STREQ("C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); // from char8_t to char EXPECT_STREQ("", ov::util::Path(u8"").string().c_str()); @@ -186,8 +185,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(u8"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(u8"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); // from char16_t to char EXPECT_STREQ("", ov::util::Path(u"").string().c_str()); @@ -195,8 +192,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(u"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(u"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); // from char32_t to char EXPECT_STREQ("", ov::util::Path(U"").string().c_str()); @@ -204,8 +199,6 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(U"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(U"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); // from char to wchar_t EXPECT_STREQ(L"", ov::util::Path("").wstring().c_str()); @@ -243,7 +236,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); // from char8_t to u16string EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); @@ -252,7 +244,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); // from char16_t to u16string EXPECT_EQ(u"", ov::util::Path(u"").u16string()); @@ -261,7 +252,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); // from char32_t to u16string EXPECT_EQ(u"", ov::util::Path(U"").u16string()); @@ -270,6 +260,18 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); + +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); // from char, char8_t, char16_t, char32_t to u16string @@ -277,6 +279,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); +#endif #if !defined(_MSC_VER) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to @@ -363,6 +366,12 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); +#endif + +#if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ + !(defined(__clang__) && __clang_major__ < 17) || \ + defined(_MSC_VER) && (defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT))) + // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); From 57e45246f0171795b5f88ad8abf07166751385d2 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 11:45:33 +0000 Subject: [PATCH 19/66] add sequence number to easier debug --- src/core/tests/file_util.cpp | 75 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 6c9f1308d584aa..a0450cf5f95939 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -262,23 +262,24 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").string().c_str()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").u16string()); // from char, char8_t, char16_t, char32_t to u16string - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").u16string()); #endif #if !defined(_MSC_VER) @@ -292,7 +293,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path("~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); // from char8_t to u32string EXPECT_EQ(U"", ov::util::Path(u8"").u32string()); @@ -301,7 +302,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").u32string()); // from char16_t to u32string EXPECT_EQ(U"", ov::util::Path(u"").u32string()); @@ -310,7 +311,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path(u"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt").u32string()); // from char32_t to u32string EXPECT_EQ(U"", ov::util::Path(U"").u32string()); @@ -319,13 +320,13 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u32string()); EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").u32string()); // from char, char8_t, char16_t, char32_t to u32string - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); #endif #if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ @@ -339,8 +340,8 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").string().c_str()); // from wchar_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(L"").wstring().c_str()); @@ -355,8 +356,8 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").u8string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").u8string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u8string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u8string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").u8string().c_str()); // from wchar_t to char16_t EXPECT_EQ(u"", ov::util::Path(L"").u16string()); @@ -364,7 +365,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"./local/file.txt", ov::util::Path(L"./local/file.txt").u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").u16string()); #endif @@ -373,14 +374,14 @@ TEST(file_util, path_cast) { defined(_MSC_VER) && (defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT))) // from char, char8_t, char16_t, char32_t to wchar_t - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); #endif #if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ @@ -393,6 +394,6 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").u32string()); #endif } From 613495ff0ae899af6b530a40cd967c37209faba1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 9 Dec 2024 13:28:49 +0000 Subject: [PATCH 20/66] add Path doxy --- .../util/include/openvino/util/file_path.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 4fb89affb2324f..9080ea5289a51e 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -13,6 +13,20 @@ namespace util { #if defined(OPENVINO_HAS_FILESYSTEM) using Path = std::filesystem::path; #elif defined(OPENVINO_HAS_EXP_FILESYSTEM) +// Known issues: +// * error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to +// * filesystem error: Cannot convert character sequence: Invalid in or incomplete multibyte or wide character + +/// +/// @typedef Path +/// @brief Alias for std::experimental::filesystem::path. +/// +/// This alias is used to simplify the usage of filesystem paths. +/// +/// @note The experimental version of std::filesystem::path may not support all features correctly. +/// It is recommended to use this alias with caution and consider upgrading to C++17 or higher +/// for full support of std::filesystem::path. +/// using Path = std::experimental::filesystem::path; #endif From d8fde2ef3e764fb91f7a650107976d533b883a8d Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Tue, 10 Dec 2024 16:23:58 +0000 Subject: [PATCH 21/66] refactor tests --- src/core/tests/file_util.cpp | 40 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index a0450cf5f95939..1ece5a6db9b7ac 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -260,8 +260,10 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u16string()); EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); +} #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +TEST(file_util, path_cast_unicode) { EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", @@ -280,12 +282,13 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").u16string()); +} #endif #if !defined(_MSC_VER) - // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to - // reference a deleted function - +// error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to +// reference a deleted function +TEST(file_util, path_cast_to_u32string) { // from char to u32string EXPECT_EQ(U"", ov::util::Path("").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); @@ -327,13 +330,15 @@ TEST(file_util, path_cast) { EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); +} #endif #if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ !(defined(__clang__) && __clang_major__ < 17)) - // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 - // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 +// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath +TEST(file_util, path_cast_from_wstring) { // from wchar_t to char EXPECT_STREQ("", ov::util::Path(L"").string().c_str()); EXPECT_STREQ("file.txt", ov::util::Path(L"file.txt").string().c_str()); @@ -366,13 +371,9 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").u16string()); +} -#endif - -#if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17) || \ - defined(_MSC_VER) && (defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT))) - +TEST(file_util, path_cast_to_wstring) { // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").wstring().c_str()); @@ -382,18 +383,23 @@ TEST(file_util, path_cast) { ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").wstring().c_str()); EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); +} #endif -#if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17) && !defined(_MSC_VER)) - // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to - // reference a deleted function - // from wchar_t to char32_t +#if (!defined(_MSC_VER) && \ + !(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ + !(defined(__clang__) && __clang_major__ < 17)) +// error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to +// reference a deleted function +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 +// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath + +TEST(file_util, path_cast_from_wstring_to_u32string) { EXPECT_EQ(U"", ov::util::Path(L"").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").u32string()); -#endif } +#endif From 39fd2c173a53ee3115e3a15c7455dcfece5d2fce Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Tue, 17 Dec 2024 17:25:29 +0100 Subject: [PATCH 22/66] fix test + format --- src/core/tests/file_util.cpp | 87 ++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 1ece5a6db9b7ac..6f46f164eef241 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -174,92 +174,92 @@ TEST(file_util, path_cast) { // from char to char EXPECT_STREQ("", ov::util::Path("").string().c_str()); EXPECT_STREQ("file.txt", ov::util::Path("file.txt").string().c_str()); - EXPECT_STREQ("./local/file.txt", ov::util::Path("./local/file.txt").string().c_str()); - EXPECT_STREQ("~/local/file.txt", ov::util::Path("~/local/file.txt").string().c_str()); - EXPECT_STREQ("/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").string().c_str()); - EXPECT_STREQ("C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path("./local/file.txt").generic_string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path("~/local/file.txt").generic_string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_string().c_str()); + EXPECT_STREQ("C:/Users/file.txt", ov::util::Path("C:\\Users\\file.txt").generic_string().c_str()); // from char8_t to char EXPECT_STREQ("", ov::util::Path(u8"").string().c_str()); EXPECT_STREQ("file.txt", ov::util::Path(u8"file.txt").string().c_str()); - EXPECT_STREQ("./local/file.txt", ov::util::Path(u8"./local/file.txt").string().c_str()); - EXPECT_STREQ("~/local/file.txt", ov::util::Path(u8"~/local/file.txt").string().c_str()); - EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(u8"./local/file.txt").generic_string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(u8"~/local/file.txt").generic_string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").generic_string().c_str()); // from char16_t to char EXPECT_STREQ("", ov::util::Path(u"").string().c_str()); EXPECT_STREQ("file.txt", ov::util::Path(u"file.txt").string().c_str()); - EXPECT_STREQ("./local/file.txt", ov::util::Path(u"./local/file.txt").string().c_str()); - EXPECT_STREQ("~/local/file.txt", ov::util::Path(u"~/local/file.txt").string().c_str()); - EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(u"./local/file.txt").generic_string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(u"~/local/file.txt").generic_string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").generic_string().c_str()); // from char32_t to char EXPECT_STREQ("", ov::util::Path(U"").string().c_str()); EXPECT_STREQ("file.txt", ov::util::Path(U"file.txt").string().c_str()); - EXPECT_STREQ("./local/file.txt", ov::util::Path(U"./local/file.txt").string().c_str()); - EXPECT_STREQ("~/local/file.txt", ov::util::Path(U"~/local/file.txt").string().c_str()); - EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(U"./local/file.txt").generic_string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(U"~/local/file.txt").generic_string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_string().c_str()); // from char to wchar_t EXPECT_STREQ(L"", ov::util::Path("").wstring().c_str()); EXPECT_STREQ(L"file.txt", ov::util::Path("file.txt").wstring().c_str()); - EXPECT_STREQ(L"./local/file.txt", ov::util::Path("./local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"~/local/file.txt", ov::util::Path("~/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path("./local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"C:/Users/file.txt", ov::util::Path("C:\\Users\\file.txt").generic_wstring().c_str()); // from char8_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(u8"").wstring().c_str()); EXPECT_STREQ(L"file.txt", ov::util::Path(u8"file.txt").wstring().c_str()); - EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u8"./local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u8"./local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").generic_wstring().c_str()); // from char16_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(u"").wstring().c_str()); EXPECT_STREQ(L"file.txt", ov::util::Path(u"file.txt").wstring().c_str()); - EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u"./local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u"~/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(u"./local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(u"~/local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").generic_wstring().c_str()); // from char32_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(U"").wstring().c_str()); EXPECT_STREQ(L"file.txt", ov::util::Path(U"file.txt").wstring().c_str()); - EXPECT_STREQ(L"./local/file.txt", ov::util::Path(U"./local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(U"~/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(U"./local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(U"~/local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string EXPECT_EQ(u"", ov::util::Path("").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").generic_u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path("C:\\Users\\file.txt").generic_u16string()); // from char8_t to u16string EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path(u8"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(u8"./local/file.txt").u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(u8"./local/file.txt").generic_u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").generic_u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path(u8"C:\\Users\\file.txt").generic_u16string()); // from char16_t to u16string EXPECT_EQ(u"", ov::util::Path(u"").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path(u"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(u"./local/file.txt").u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u"~/local/file.txt").u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(u"./local/file.txt").generic_u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u"~/local/file.txt").generic_u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path(u"C:\\Users\\file.txt").generic_u16string()); // from char32_t to u16string EXPECT_EQ(u"", ov::util::Path(U"").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path(U"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(U"./local/file.txt").u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(U"./local/file.txt").generic_u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").generic_u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path(U"C:\\Users\\file.txt").generic_u16string()); } #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT @@ -386,8 +386,7 @@ TEST(file_util, path_cast_to_wstring) { } #endif -#if (!defined(_MSC_VER) && \ - !(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ +#if (!defined(_MSC_VER) && !(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ !(defined(__clang__) && __clang_major__ < 17)) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function From 45fb8ad87feebd43933df1af1a5a441427a2a7c5 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Tue, 17 Dec 2024 18:01:33 +0100 Subject: [PATCH 23/66] unify windows path test --- src/core/tests/file_util.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 6f46f164eef241..cb949513d9c9c2 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -177,7 +177,7 @@ TEST(file_util, path_cast) { EXPECT_STREQ("./local/file.txt", ov::util::Path("./local/file.txt").generic_string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path("~/local/file.txt").generic_string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_string().c_str()); - EXPECT_STREQ("C:/Users/file.txt", ov::util::Path("C:\\Users\\file.txt").generic_string().c_str()); + EXPECT_STREQ("C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").string().c_str()); // from char8_t to char EXPECT_STREQ("", ov::util::Path(u8"").string().c_str()); @@ -206,7 +206,7 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"./local/file.txt", ov::util::Path("./local/file.txt").generic_wstring().c_str()); EXPECT_STREQ(L"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_wstring().c_str()); - EXPECT_STREQ(L"C:/Users/file.txt", ov::util::Path("C:\\Users\\file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").wstring().c_str()); // from char8_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(u8"").wstring().c_str()); @@ -235,7 +235,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path("C:\\Users\\file.txt").generic_u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u16string()); // from char8_t to u16string EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); @@ -243,7 +243,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"./local/file.txt", ov::util::Path(u8"./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").generic_u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path(u8"C:\\Users\\file.txt").generic_u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u16string()); // from char16_t to u16string EXPECT_EQ(u"", ov::util::Path(u"").u16string()); @@ -251,7 +251,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"./local/file.txt", ov::util::Path(u"./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u"~/local/file.txt").generic_u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path(u"C:\\Users\\file.txt").generic_u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u16string()); // from char32_t to u16string EXPECT_EQ(u"", ov::util::Path(U"").u16string()); @@ -259,7 +259,7 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"./local/file.txt", ov::util::Path(U"./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").generic_u16string()); EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:/Users/file.txt", ov::util::Path(U"C:\\Users\\file.txt").generic_u16string()); + EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); } #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT From 6357c418b41773b263bceb5f38407b4ec7b89620 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Tue, 17 Dec 2024 18:34:42 +0100 Subject: [PATCH 24/66] unify windows path test2 --- src/core/tests/file_util.cpp | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index cb949513d9c9c2..9a8ecd20734b80 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -342,35 +342,36 @@ TEST(file_util, path_cast_from_wstring) { // from wchar_t to char EXPECT_STREQ("", ov::util::Path(L"").string().c_str()); EXPECT_STREQ("file.txt", ov::util::Path(L"file.txt").string().c_str()); - EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").string().c_str()); - EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").string().c_str()); - EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").string().c_str()); + EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").generic_string().c_str()); + EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_string().c_str()); + EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").string().c_str()); + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").generic_string().c_str()); // from wchar_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(L"").wstring().c_str()); EXPECT_STREQ(L"file.txt", ov::util::Path(L"file.txt").wstring().c_str()); - EXPECT_STREQ(L"./local/file.txt", ov::util::Path(L"./local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(L"~/local/file.txt").wstring().c_str()); - EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").wstring().c_str()); + EXPECT_STREQ(L"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - EXPECT_STREQ("", ov::util::Path(L"").u8string().c_str()); - EXPECT_STREQ("file.txt", ov::util::Path(L"file.txt").u8string().c_str()); - EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").u8string().c_str()); - EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").u8string().c_str()); - EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u8string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").u8string().c_str()); + EXPECT_STREQ(u8"", ov::util::Path(L"").u8string().c_str()); + EXPECT_STREQ(u8"file.txt", ov::util::Path(L"file.txt").u8string().c_str()); + EXPECT_STREQ(u8"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u8string().c_str()); + EXPECT_STREQ(u8"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u8string().c_str()); + EXPECT_STREQ(u8"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_u8string().c_str()); + EXPECT_STREQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string().c_str()); // from wchar_t to char16_t EXPECT_EQ(u"", ov::util::Path(L"").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path(L"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(L"./local/file.txt").u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").u16string()); + EXPECT_EQ(u"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u16string()); + EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u16string()); + EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").generic_u16string()); } TEST(file_util, path_cast_to_wstring) { From 0cac7fb6778fbe9ee8dffbc1aad15b5f5b74d402 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 18 Dec 2024 13:57:58 +0100 Subject: [PATCH 25/66] skip test cast form u8, u16 on windows platform --- src/core/tests/file_util.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 9a8ecd20734b80..2ff9882039fd12 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -262,28 +262,30 @@ TEST(file_util, path_cast) { EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); } -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT TEST(file_util, path_cast_unicode) { EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").string().c_str()); + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string().c_str()); +#if !defined(_MSC_VER) EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").string().c_str()); EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").string().c_str()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").u16string()); +#endif // from char, char8_t, char16_t, char32_t to u16string - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); +#if !defined(_MSC_VER) EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").u16string()); -} #endif +} #if !defined(_MSC_VER) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to From 0b4850f391aa61ce3099af7ae8fcdea480c4f1af Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 19 Dec 2024 08:31:32 +0000 Subject: [PATCH 26/66] unify cpp version check define names --- src/core/include/openvino/core/graph_util.hpp | 6 +++--- src/core/include/openvino/core/visibility.hpp | 16 ++++++++-------- src/core/include/openvino/pass/serialize.hpp | 4 ++-- src/core/tests/frontend/frontend_manager.cpp | 2 +- .../pass/serialization/deterministicity.cpp | 2 +- src/core/tests/pass/serialization/serialize.cpp | 2 +- .../include/openvino/frontend/frontend.hpp | 10 +++++----- .../tests/frontend/shared/src/conversion.cpp | 2 +- src/inference/include/openvino/runtime/core.hpp | 16 ++++++++-------- src/inference/tests/functional/ov_core_test.cpp | 2 +- .../tests/functional/ov_extension_test.cpp | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/core/include/openvino/core/graph_util.hpp b/src/core/include/openvino/core/graph_util.hpp index f5694ca89fee51..4e67a6389060ed 100644 --- a/src/core/include/openvino/core/graph_util.hpp +++ b/src/core/include/openvino/core/graph_util.hpp @@ -21,7 +21,7 @@ #include "openvino/op/parameter.hpp" #include "openvino/pass/serialize.hpp" -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 # include #endif @@ -299,7 +299,7 @@ void serialize(const std::shared_ptr& m, const std::string& bin_path = "", ov::pass::Serialize::Version version = ov::pass::Serialize::Version::UNSPECIFIED); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> void serialize(const std::shared_ptr& m, const Path& xml_path, @@ -327,7 +327,7 @@ void save_model(const std::shared_ptr& model, bool compress_to_fp16 = true); #endif -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> void save_model(const std::shared_ptr& model, const Path& output_model, bool compress_to_fp16 = true) { save_model(model, output_model.string(), compress_to_fp16); diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp index 2dabbb42d2df07..d5ed36fd4022a7 100644 --- a/src/core/include/openvino/core/visibility.hpp +++ b/src/core/include/openvino/core/visibility.hpp @@ -80,26 +80,26 @@ #if !(defined(_MSC_VER) && __cplusplus == 199711L) # if __cplusplus >= 201103L -# define OPENVINO_CPP_VER_11 +# define OPENVINO_CPP_VER_AT_LEAST_11 # if __cplusplus >= 201402L -# define OPENVINO_CPP_VER_14 +# define OPENVINO_CPP_VER_AT_LEAST_14 # if __cplusplus >= 201703L -# define OPENVINO_CPP_VER_17 +# define OPENVINO_CPP_VER_AT_LEAST_17 # if __cplusplus >= 202002L -# define OPENVINO_CPP_VER_20 +# define OPENVINO_CPP_VER_AT_LEAST_20 # endif # endif # endif # endif #elif defined(_MSC_VER) && __cplusplus == 199711L # if _MSVC_LANG >= 201103L -# define OPENVINO_CPP_VER_11 +# define OPENVINO_CPP_VER_AT_LEAST_11 # if _MSVC_LANG >= 201402L -# define OPENVINO_CPP_VER_14 +# define OPENVINO_CPP_VER_AT_LEAST_14 # if _MSVC_LANG >= 201703L -# define OPENVINO_CPP_VER_17 +# define OPENVINO_CPP_VER_AT_LEAST_17 # if _MSVC_LANG >= 202002L -# define OPENVINO_CPP_VER_20 +# define OPENVINO_CPP_VER_AT_LEAST_20 # endif # endif # endif diff --git a/src/core/include/openvino/pass/serialize.hpp b/src/core/include/openvino/pass/serialize.hpp index d0eaadde346bf6..7f9c27d1798950 100644 --- a/src/core/include/openvino/pass/serialize.hpp +++ b/src/core/include/openvino/pass/serialize.hpp @@ -11,7 +11,7 @@ #include "openvino/opsets/opset.hpp" #include "openvino/pass/pass.hpp" -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 # include #endif @@ -39,7 +39,7 @@ class OPENVINO_API Serialize : public ov::pass::ModelPass { Serialize(const std::string& xmlPath, const std::string& binPath, Version version = Version::UNSPECIFIED); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 Serialize(const std::filesystem::path& xmlPath, const std::filesystem::path& binPath, Version version = Version::UNSPECIFIED) diff --git a/src/core/tests/frontend/frontend_manager.cpp b/src/core/tests/frontend/frontend_manager.cpp index 31e643e7209bdb..f9e2a744baa13c 100644 --- a/src/core/tests/frontend/frontend_manager.cpp +++ b/src/core/tests/frontend/frontend_manager.cpp @@ -480,7 +480,7 @@ TEST(FrontEndManagerTest, Exception_Safety_Input_Model_set_tensor_partial_value) CHECK_EXCEPTION_INPUT_MODEL(input_model->set_tensor_partial_value({}, {}, {})) } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 TEST(FrontEndManagerTest, testFEMDestroy_InputModelHolderUsingPath) { InputModel::Ptr input_model; diff --git a/src/core/tests/pass/serialization/deterministicity.cpp b/src/core/tests/pass/serialization/deterministicity.cpp index a93f092889d2a1..dd73ef5df7ec9b 100644 --- a/src/core/tests/pass/serialization/deterministicity.cpp +++ b/src/core/tests/pass/serialization/deterministicity.cpp @@ -296,7 +296,7 @@ TEST_P(SerializationDeterministicityInputOutputTest, FromIrModel) { EXPECT_TRUE(files_equal(xml_2, xml_1)); } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 TEST_P(SerializationDeterministicityInputOutputTest, FromOvModelBybPath) { auto irVersion = GetParam(); diff --git a/src/core/tests/pass/serialization/serialize.cpp b/src/core/tests/pass/serialization/serialize.cpp index 5cb1965feebdd7..463975c2814ae8 100644 --- a/src/core/tests/pass/serialization/serialize.cpp +++ b/src/core/tests/pass/serialization/serialize.cpp @@ -74,7 +74,7 @@ TEST_P(SerializationTest, SaveModel) { }); } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 TEST_P(SerializationTest, CompareFunctionsByPath) { const auto out_xml_path = std::filesystem::path(m_out_xml_path); const auto out_bin_path = std::filesystem::path(m_out_bin_path); diff --git a/src/frontends/common/include/openvino/frontend/frontend.hpp b/src/frontends/common/include/openvino/frontend/frontend.hpp index bc944c17dbc0dd..1bbdd000b68595 100644 --- a/src/frontends/common/include/openvino/frontend/frontend.hpp +++ b/src/frontends/common/include/openvino/frontend/frontend.hpp @@ -15,7 +15,7 @@ #include "openvino/frontend/input_model.hpp" #include "openvino/frontend/visibility.hpp" -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 # include #endif @@ -54,7 +54,7 @@ class FRONTEND_API FrontEnd { /// \return true if model recognized, false - otherwise. template inline bool supported(const Types&... vars) const { -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 if constexpr ((std::is_same_v || ...)) { return supported_impl({path_as_str_or_forward(vars)...}); } else @@ -74,7 +74,7 @@ class FRONTEND_API FrontEnd { /// \return Loaded input model. template inline InputModel::Ptr load(const Types&... vars) const { -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 if constexpr ((std::is_same_v || ...)) { return load_impl({path_as_str_or_forward(vars)...}); } else @@ -135,7 +135,7 @@ class FRONTEND_API FrontEnd { /// \{ void add_extension(const std::string& library_path); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 void add_extension(const std::filesystem::path& library_path) { add_extension(library_path.string()); } @@ -185,7 +185,7 @@ class FRONTEND_API FrontEnd { static std::shared_ptr create_copy(const std::shared_ptr& ov_model, const std::shared_ptr& shared_object); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template static constexpr auto path_as_str_or_forward(T&& p) { if constexpr (std::is_same_v>) { diff --git a/src/frontends/tests/frontend/shared/src/conversion.cpp b/src/frontends/tests/frontend/shared/src/conversion.cpp index 058d5534965436..1a545b92708d76 100644 --- a/src/frontends/tests/frontend/shared/src/conversion.cpp +++ b/src/frontends/tests/frontend/shared/src/conversion.cpp @@ -96,7 +96,7 @@ TEST_P(FrontEndConversionExtensionTest, TestConversionExtensionViaSO) { ASSERT_NE(model, nullptr); } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 TEST_P(FrontEndConversionExtensionTest, TestConversionExtensionViaSOByPath) { auto frontend = m_param.m_frontend; const std::filesystem::path lib_path = get_lib_path("test_builtin_extensions"); diff --git a/src/inference/include/openvino/runtime/core.hpp b/src/inference/include/openvino/runtime/core.hpp index 2ca6dc83bcf726..1ba4fe58ff473d 100644 --- a/src/inference/include/openvino/runtime/core.hpp +++ b/src/inference/include/openvino/runtime/core.hpp @@ -25,7 +25,7 @@ #include "openvino/runtime/remote_context.hpp" #include "openvino/runtime/tensor.hpp" -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 # include #endif @@ -109,7 +109,7 @@ class OPENVINO_RUNTIME_API Core { const std::string& bin_path = {}, const ov::AnyMap& properties = {}) const; -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> auto read_model(const Path& model_path, const Path& bin_path = {}, const ov::AnyMap& properties = {}) const { return read_model(model_path.string(), bin_path.string(), properties); @@ -141,7 +141,7 @@ class OPENVINO_RUNTIME_API Core { return read_model(model_path, bin_path, AnyMap{std::forward(properties)...}); } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template && (sizeof...(Properties) > 0)>* = nullptr> @@ -250,7 +250,7 @@ class OPENVINO_RUNTIME_API Core { */ CompiledModel compile_model(const std::string& model_path, const AnyMap& properties = {}); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> auto compile_model(const Path& model_path, const AnyMap& properties = {}) const { return compile_model(model_path.string(), properties); @@ -283,7 +283,7 @@ class OPENVINO_RUNTIME_API Core { return compile_model(model_path, AnyMap{std::forward(properties)...}); } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> auto compile_model(const Path& model_path, Properties&&... properties) { return compile_model(model_path.string(), std::forward(properties)...); @@ -317,7 +317,7 @@ class OPENVINO_RUNTIME_API Core { const std::string& device_name, const AnyMap& properties = {}); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> auto compile_model(const Path& model_path, const std::string& device_name, const AnyMap& properties = {}) { return compile_model(model_path.string(), device_name, properties); @@ -353,7 +353,7 @@ class OPENVINO_RUNTIME_API Core { return compile_model(model_path, device_name, AnyMap{std::forward(properties)...}); } -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> auto compile_model(const Path& model_path, const std::string& device_name, Properties&&... properties) { return compile_model(model_path.string(), device_name, std::forward(properties)...); @@ -444,7 +444,7 @@ class OPENVINO_RUNTIME_API Core { */ void add_extension(const std::string& library_path); -#ifdef OPENVINO_CPP_VER_17 +#ifdef OPENVINO_CPP_VER_AT_LEAST_17 template >* = nullptr> void add_extension(const Path& model_path) { add_extension(model_path.string()); diff --git a/src/inference/tests/functional/ov_core_test.cpp b/src/inference/tests/functional/ov_core_test.cpp index 60f91b85b3338a..92290b08213b6c 100644 --- a/src/inference/tests/functional/ov_core_test.cpp +++ b/src/inference/tests/functional/ov_core_test.cpp @@ -114,7 +114,7 @@ TEST_F(CoreBaseTest, LoadOVFolderOverCWPathPluginXML) { #endif -#if defined(OPENVINO_CPP_VER_17) && defined(ENABLE_OV_IR_FRONTEND) +#if defined(OPENVINO_CPP_VER_AT_LEAST_17) && defined(ENABLE_OV_IR_FRONTEND) namespace ov::test { TEST_F(CoreBaseTest, read_model_with_std_fs_path) { generate_test_model_files("test-model"); diff --git a/src/inference/tests/functional/ov_extension_test.cpp b/src/inference/tests/functional/ov_extension_test.cpp index b840c430d092e9..020b6ccfe2bdd9 100644 --- a/src/inference/tests/functional/ov_extension_test.cpp +++ b/src/inference/tests/functional/ov_extension_test.cpp @@ -82,7 +82,7 @@ class CustomReLU : public ov::op::Op { }; #if defined(ENABLE_OV_IR_FRONTEND) -# ifdef OPENVINO_CPP_VER_17 +# ifdef OPENVINO_CPP_VER_AT_LEAST_17 TEST_F(OVExtensionTests, ReshapeIRWithNewExtensionsPathLib) { core.add_extension(std::filesystem::path(getOVExtensionPath())); test(); From 9349de1e42fae9f1170ffb8caed927bc3fd5b3ce Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 19 Dec 2024 14:52:12 +0100 Subject: [PATCH 27/66] set windows platform tests --- src/core/tests/file_util.cpp | 63 ++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 2ff9882039fd12..f05e8782694b70 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -263,31 +263,35 @@ TEST(file_util, path_cast) { } TEST(file_util, path_cast_unicode) { - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string().c_str()); -#if !defined(_MSC_VER) - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").string().c_str()); -#endif + EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string()); + EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); + EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); + + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); // from char, char8_t, char16_t, char32_t to u16string + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); -#if !defined(_MSC_VER) - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").u16string()); -#endif + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); } #if !defined(_MSC_VER) +TEST(file_util, path_cast_unicode_msc_skip) { + EXPECT_EQ("/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", + ov::util::Path(u8"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); + EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); +} // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function TEST(file_util, path_cast_to_u32string) { @@ -379,13 +383,9 @@ TEST(file_util, path_cast_from_wstring) { TEST(file_util, path_cast_to_wstring) { // from char, char8_t, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").wstring().c_str()); - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").generic_wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_wstring().c_str()); } #endif @@ -402,6 +402,15 @@ TEST(file_util, path_cast_from_wstring_to_u32string) { EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").u32string()); + EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").u32string()); } + +TEST(file_util, path_cast_to_wstring_msc_skip) { + // from char8_t, char16_t to wchar_t + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); + EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").wstring().c_str()); +} + #endif From 37dcda1e9ff5ae78367adb468b851fc5019cc276 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 09:35:46 +0100 Subject: [PATCH 28/66] use EXPECT_EQ instead EXPECT_STREQ for u8 --- src/core/tests/file_util.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index f05e8782694b70..b237b7bcf432fa 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -362,13 +362,13 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - EXPECT_STREQ(u8"", ov::util::Path(L"").u8string().c_str()); - EXPECT_STREQ(u8"file.txt", ov::util::Path(L"file.txt").u8string().c_str()); - EXPECT_STREQ(u8"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u8string().c_str()); - EXPECT_STREQ(u8"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u8string().c_str()); - EXPECT_STREQ(u8"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_u8string().c_str()); - EXPECT_STREQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string().c_str()); + EXPECT_EQ(u8"", ov::util::Path(L"").u8string()); + EXPECT_EQ(u8"file.txt", ov::util::Path(L"file.txt").u8string()); + EXPECT_EQ(u8"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_EQ(u8"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_EQ(u8"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); // from wchar_t to char16_t EXPECT_EQ(u"", ov::util::Path(L"").u16string()); From 9f452447450a3fcea03146c596e2c884476536ae Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 10:43:13 +0100 Subject: [PATCH 29/66] fix test --- src/core/tests/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index b237b7bcf432fa..589e7080034204 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -407,9 +407,9 @@ TEST(file_util, path_cast_from_wstring_to_u32string) { TEST(file_util, path_cast_to_wstring_msc_skip) { // from char8_t, char16_t to wchar_t - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); - EXPECT_STREQ(L"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").wstring().c_str()); } From bf0e7f0f2f7d3750d69f46490ad8ea9718011258 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 12:16:48 +0100 Subject: [PATCH 30/66] fix path_cast_unicode test 4.txt --- src/core/tests/file_util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 589e7080034204..0d9603d0836e58 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -267,8 +267,8 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); + EXPECT_STREQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string().c_str()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", @@ -381,7 +381,7 @@ TEST(file_util, path_cast_from_wstring) { } TEST(file_util, path_cast_to_wstring) { - // from char, char8_t, char16_t, char32_t to wchar_t + // from char, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").generic_wstring().c_str()); EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", From 3dbce3a565e0aa3b99e241fa7deb379388888ae7 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 12:58:01 +0100 Subject: [PATCH 31/66] skip test for mvs --- src/core/tests/file_util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 0d9603d0836e58..0334b30b4a2815 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -267,10 +267,6 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); - EXPECT_STREQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string().c_str()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); @@ -287,6 +283,10 @@ TEST(file_util, path_cast_unicode) { TEST(file_util, path_cast_unicode_msc_skip) { EXPECT_EQ("/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", From 548f44acf818d0276496f8588fa871c5c8da6332 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 13:55:53 +0100 Subject: [PATCH 32/66] skip test for mvs2 --- src/core/tests/file_util.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 0334b30b4a2815..e294918acfee5e 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -267,9 +267,6 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); - // from char, char8_t, char16_t, char32_t to u16string EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); @@ -287,6 +284,8 @@ TEST(file_util, path_cast_unicode_msc_skip) { ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", From 2e50563fb360807b00097d2214835ae5d9b909ff Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 15:22:09 +0100 Subject: [PATCH 33/66] skip test --- src/core/tests/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index e294918acfee5e..b279b4633455b2 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -280,8 +280,8 @@ TEST(file_util, path_cast_unicode) { TEST(file_util, path_cast_unicode_msc_skip) { EXPECT_EQ("/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); + // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + // ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", From 28a03c476b6d95c96cbdea200efed6b972b02c14 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 15:36:59 +0100 Subject: [PATCH 34/66] skip test2 --- src/core/tests/file_util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index b279b4633455b2..60b2769aa063ce 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -282,10 +282,10 @@ TEST(file_util, path_cast_unicode_msc_skip) { ov::util::Path(u8"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", // ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); + // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", + // ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); + // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", + // ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", From 61edd0cc398deaf9cf40ca7fb412bc72ca894ef2 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 20 Dec 2024 15:51:33 +0100 Subject: [PATCH 35/66] skip all checks generic_u8string at test path_cast_unicode --- src/core/tests/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 60b2769aa063ce..c6a978f0bf78b3 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -286,8 +286,8 @@ TEST(file_util, path_cast_unicode_msc_skip) { // ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", // ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); + // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", + // ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); } From cbb153dc33aad5c6028601ddba5b142a4b6db67e Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Tue, 7 Jan 2025 22:37:20 +0100 Subject: [PATCH 36/66] use c_str cast at empty string tests --- src/core/tests/file_util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index c6a978f0bf78b3..1f17ec3a76615b 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -230,7 +230,7 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string - EXPECT_EQ(u"", ov::util::Path("").u16string()); + EXPECT_EQ(u"", ov::util::Path("").u16string().c_str()); EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_u16string()); @@ -295,7 +295,7 @@ TEST(file_util, path_cast_unicode_msc_skip) { // reference a deleted function TEST(file_util, path_cast_to_u32string) { // from char to u32string - EXPECT_EQ(U"", ov::util::Path("").u32string()); + EXPECT_EQ(U"", ov::util::Path("").u32string().c_str()); EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); EXPECT_EQ(U"./local/file.txt", ov::util::Path("./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path("~/local/file.txt").u32string()); @@ -361,7 +361,7 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - EXPECT_EQ(u8"", ov::util::Path(L"").u8string()); + EXPECT_EQ(u8"", ov::util::Path(L"").u8string().c_str()); EXPECT_EQ(u8"file.txt", ov::util::Path(L"file.txt").u8string()); EXPECT_EQ(u8"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u8string()); EXPECT_EQ(u8"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u8string()); From d0a56a9119374c51501a9c6bbcf6d5a34f267786 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Tue, 7 Jan 2025 23:24:23 +0100 Subject: [PATCH 37/66] revert use c_str cast at empty string tests --- src/core/tests/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 1f17ec3a76615b..116673cb10f66a 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -230,7 +230,7 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string - EXPECT_EQ(u"", ov::util::Path("").u16string().c_str()); + EXPECT_EQ(u"", ov::util::Path("").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_u16string()); @@ -295,7 +295,7 @@ TEST(file_util, path_cast_unicode_msc_skip) { // reference a deleted function TEST(file_util, path_cast_to_u32string) { // from char to u32string - EXPECT_EQ(U"", ov::util::Path("").u32string().c_str()); + EXPECT_EQ(U"", ov::util::Path("").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); EXPECT_EQ(U"./local/file.txt", ov::util::Path("./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path("~/local/file.txt").u32string()); From 4ef09e12fdda2034b1bb466bba6aa65a057d0e9e Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 8 Jan 2025 09:44:09 +0100 Subject: [PATCH 38/66] turn off failing tests --- src/core/tests/file_util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 116673cb10f66a..faec4be57883b3 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -230,7 +230,7 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string - EXPECT_EQ(u"", ov::util::Path("").u16string()); + // EXPECT_EQ(u"", ov::util::Path("").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").generic_u16string()); EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_u16string()); @@ -295,7 +295,7 @@ TEST(file_util, path_cast_unicode_msc_skip) { // reference a deleted function TEST(file_util, path_cast_to_u32string) { // from char to u32string - EXPECT_EQ(U"", ov::util::Path("").u32string()); + // EXPECT_EQ(U"", ov::util::Path("").u32string()); EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); EXPECT_EQ(U"./local/file.txt", ov::util::Path("./local/file.txt").u32string()); EXPECT_EQ(U"~/local/file.txt", ov::util::Path("~/local/file.txt").u32string()); @@ -361,7 +361,7 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - EXPECT_EQ(u8"", ov::util::Path(L"").u8string().c_str()); + // EXPECT_EQ(u8"", ov::util::Path(L"").u8string()); EXPECT_EQ(u8"file.txt", ov::util::Path(L"file.txt").u8string()); EXPECT_EQ(u8"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u8string()); EXPECT_EQ(u8"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u8string()); From e152a9bd8554054bfc08d74a09fa470324328490 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 9 Jan 2025 12:52:40 +0000 Subject: [PATCH 39/66] use std string as unicode representation at test checks to avoid deleted operator<< --- src/core/tests/file_util.cpp | 39 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index faec4be57883b3..44e37f3e3f66cd 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -230,12 +230,12 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string - // EXPECT_EQ(u"", ov::util::Path("").u16string()); - EXPECT_EQ(u"file.txt", ov::util::Path("file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path("./local/file.txt").generic_u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path("~/local/file.txt").generic_u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u16string()); + EXPECT_EQ(std::u16string{u""}, ov::util::Path("").u16string()); + EXPECT_EQ(std::u16string{u"file.txt"}, ov::util::Path("file.txt").u16string()); + EXPECT_EQ(std::u16string{u"./local/file.txt"}, ov::util::Path("./local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string{u"~/local/file.txt"}, ov::util::Path("~/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string{u"/usr/local/file.txt"}, ov::util::Path("/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string{u"C:\\Users\\file.txt"}, ov::util::Path("C:\\Users\\file.txt").u16string()); // from char8_t to u16string EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); @@ -295,13 +295,14 @@ TEST(file_util, path_cast_unicode_msc_skip) { // reference a deleted function TEST(file_util, path_cast_to_u32string) { // from char to u32string - // EXPECT_EQ(U"", ov::util::Path("").u32string()); - EXPECT_EQ(U"file.txt", ov::util::Path("file.txt").u32string()); - EXPECT_EQ(U"./local/file.txt", ov::util::Path("./local/file.txt").u32string()); - EXPECT_EQ(U"~/local/file.txt", ov::util::Path("~/local/file.txt").u32string()); - EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path("/usr/local/file.txt").u32string()); - EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path("C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); + EXPECT_EQ(std::u32string{U""}, ov::util::Path("").u32string()); + EXPECT_EQ(std::u32string{U"file.txt"}, ov::util::Path("file.txt").u32string()); + EXPECT_EQ(std::u32string{U"./local/file.txt"}, ov::util::Path("./local/file.txt").u32string()); + EXPECT_EQ(std::u32string{U"~/local/file.txt"}, ov::util::Path("~/local/file.txt").u32string()); + EXPECT_EQ(std::u32string{U"/usr/local/file.txt"}, ov::util::Path("/usr/local/file.txt").u32string()); + EXPECT_EQ(std::u32string{U"C:\\Users\\file.txt"}, ov::util::Path("C:\\Users\\file.txt").u32string()); + EXPECT_EQ(std::u32string{U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt"}, + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); // from char8_t to u32string EXPECT_EQ(U"", ov::util::Path(u8"").u32string()); @@ -361,12 +362,12 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - // EXPECT_EQ(u8"", ov::util::Path(L"").u8string()); - EXPECT_EQ(u8"file.txt", ov::util::Path(L"file.txt").u8string()); - EXPECT_EQ(u8"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u8string()); - EXPECT_EQ(u8"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u8string()); - EXPECT_EQ(u8"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_u8string()); - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", + EXPECT_EQ(std::string{u8""}, ov::util::Path(L"").u8string()); + EXPECT_EQ(std::string{u8"file.txt"}, ov::util::Path(L"file.txt").u8string()); + EXPECT_EQ(std::string{u8"./local/file.txt"}, ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_EQ(std::string{u8"~/local/file.txt"}, ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_EQ(std::string{u8"/usr/local/file.txt"}, ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_EQ(std::string{u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"}, ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); // from wchar_t to char16_t From c7408f946af2a069b0e64dfa4cfa7ca0fbb6a360 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 9 Jan 2025 13:18:05 +0000 Subject: [PATCH 40/66] do not initialize with initializaiton list --- src/core/tests/file_util.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 44e37f3e3f66cd..09822ad2f9862b 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -362,12 +362,12 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - EXPECT_EQ(std::string{u8""}, ov::util::Path(L"").u8string()); - EXPECT_EQ(std::string{u8"file.txt"}, ov::util::Path(L"file.txt").u8string()); - EXPECT_EQ(std::string{u8"./local/file.txt"}, ov::util::Path(L"./local/file.txt").generic_u8string()); - EXPECT_EQ(std::string{u8"~/local/file.txt"}, ov::util::Path(L"~/local/file.txt").generic_u8string()); - EXPECT_EQ(std::string{u8"/usr/local/file.txt"}, ov::util::Path(L"/usr/local/file.txt").generic_u8string()); - EXPECT_EQ(std::string{u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"}, + EXPECT_EQ(std::string(u8""), ov::util::Path(L"").u8string()); + EXPECT_EQ(std::string(u8"file.txt"), ov::util::Path(L"file.txt").u8string()); + EXPECT_EQ(std::string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); // from wchar_t to char16_t From 609486b6e3268e23881e78afffba0e28511d87aa Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 9 Jan 2025 14:43:24 +0100 Subject: [PATCH 41/66] do not initialize with initializaiton list 2 --- src/core/tests/file_util.cpp | 74 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 09822ad2f9862b..1ce88801bbb0b0 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -230,36 +230,36 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string - EXPECT_EQ(std::u16string{u""}, ov::util::Path("").u16string()); - EXPECT_EQ(std::u16string{u"file.txt"}, ov::util::Path("file.txt").u16string()); - EXPECT_EQ(std::u16string{u"./local/file.txt"}, ov::util::Path("./local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string{u"~/local/file.txt"}, ov::util::Path("~/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string{u"/usr/local/file.txt"}, ov::util::Path("/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string{u"C:\\Users\\file.txt"}, ov::util::Path("C:\\Users\\file.txt").u16string()); + EXPECT_EQ(std::u16string(u""), ov::util::Path("").u16string()); + EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path("file.txt").u16string()); + EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path("./local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path("~/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path("/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path("C:\\Users\\file.txt").u16string()); // from char8_t to u16string - EXPECT_EQ(u"", ov::util::Path(u8"").u16string()); - EXPECT_EQ(u"file.txt", ov::util::Path(u8"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(u8"./local/file.txt").generic_u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").generic_u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(std::u16string(u""), ov::util::Path(u8"").u16string()); + EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path(u8"file.txt").u16string()); + EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path(u8"./local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path(u8"~/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path(u8"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path(u8"C:\\Users\\file.txt").u16string()); // from char16_t to u16string - EXPECT_EQ(u"", ov::util::Path(u"").u16string()); - EXPECT_EQ(u"file.txt", ov::util::Path(u"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(u"./local/file.txt").generic_u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(u"~/local/file.txt").generic_u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(std::u16string(u""), ov::util::Path(u"").u16string()); + EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path(u"file.txt").u16string()); + EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path(u"./local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path(u"~/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path(u"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path(u"C:\\Users\\file.txt").u16string()); // from char32_t to u16string - EXPECT_EQ(u"", ov::util::Path(U"").u16string()); - EXPECT_EQ(u"file.txt", ov::util::Path(U"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(U"./local/file.txt").generic_u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(U"~/local/file.txt").generic_u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u16string()); + EXPECT_EQ(std::u16string(u""), ov::util::Path(U"").u16string()); + EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path(U"file.txt").u16string()); + EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path(U"./local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path(U"~/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path(U"/usr/local/file.txt").generic_u16string()); + EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path(U"C:\\Users\\file.txt").u16string()); } TEST(file_util, path_cast_unicode) { @@ -295,13 +295,13 @@ TEST(file_util, path_cast_unicode_msc_skip) { // reference a deleted function TEST(file_util, path_cast_to_u32string) { // from char to u32string - EXPECT_EQ(std::u32string{U""}, ov::util::Path("").u32string()); - EXPECT_EQ(std::u32string{U"file.txt"}, ov::util::Path("file.txt").u32string()); - EXPECT_EQ(std::u32string{U"./local/file.txt"}, ov::util::Path("./local/file.txt").u32string()); - EXPECT_EQ(std::u32string{U"~/local/file.txt"}, ov::util::Path("~/local/file.txt").u32string()); - EXPECT_EQ(std::u32string{U"/usr/local/file.txt"}, ov::util::Path("/usr/local/file.txt").u32string()); - EXPECT_EQ(std::u32string{U"C:\\Users\\file.txt"}, ov::util::Path("C:\\Users\\file.txt").u32string()); - EXPECT_EQ(std::u32string{U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt"}, + EXPECT_EQ(std::u32string(U""), ov::util::Path("").u32string()); + EXPECT_EQ(std::u32string(U"file.txt"), ov::util::Path("file.txt").u32string()); + EXPECT_EQ(std::u32string(U"./local/file.txt"), ov::util::Path("./local/file.txt").u32string()); + EXPECT_EQ(std::u32string(U"~/local/file.txt"), ov::util::Path("~/local/file.txt").u32string()); + EXPECT_EQ(std::u32string(U"/usr/local/file.txt"), ov::util::Path("/usr/local/file.txt").u32string()); + EXPECT_EQ(std::u32string(U"C:\\Users\\file.txt"), ov::util::Path("C:\\Users\\file.txt").u32string()); + EXPECT_EQ(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt"), ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); // from char8_t to u32string @@ -362,12 +362,12 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char8_t - EXPECT_EQ(std::string(u8""), ov::util::Path(L"").u8string()); - EXPECT_EQ(std::string(u8"file.txt"), ov::util::Path(L"file.txt").u8string()); - EXPECT_EQ(std::string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); - EXPECT_EQ(std::string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); - EXPECT_EQ(std::string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), + EXPECT_EQ(std::u8string(u8""), ov::util::Path(L"").u8string()); + EXPECT_EQ(std::u8string(u8"file.txt"), ov::util::Path(L"file.txt").u8string()); + EXPECT_EQ(std::u8string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_EQ(std::u8string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_EQ(std::u8string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); // from wchar_t to char16_t From b11804d77f9ada75514e94934b2ebdbf1d274a44 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 9 Jan 2025 17:56:22 +0100 Subject: [PATCH 42/66] test C++20 u8string --- src/core/tests/file_util.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 1ce88801bbb0b0..afb4739d6d3047 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -361,15 +361,6 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_wstring().c_str()); EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); - // from wchar_t to char8_t - EXPECT_EQ(std::u8string(u8""), ov::util::Path(L"").u8string()); - EXPECT_EQ(std::u8string(u8"file.txt"), ov::util::Path(L"file.txt").u8string()); - EXPECT_EQ(std::u8string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); - EXPECT_EQ(std::u8string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); - EXPECT_EQ(std::u8string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); - EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); - // from wchar_t to char16_t EXPECT_EQ(u"", ov::util::Path(L"").u16string()); EXPECT_EQ(u"file.txt", ov::util::Path(L"file.txt").u16string()); @@ -389,6 +380,27 @@ TEST(file_util, path_cast_to_wstring) { } #endif +TEST(file_util, path_cast_from_wstring_to_char8_t) { + // from wchar_t to char8_t +#if defined(OPENVINO_CPP_VER_AT_LEAST_20) + EXPECT_EQ(std::u8string(u8""), ov::util::Path(L"").u8string()); + EXPECT_EQ(std::u8string(u8"file.txt"), ov::util::Path(L"file.txt").u8string()); + EXPECT_EQ(std::u8string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_EQ(std::u8string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_EQ(std::u8string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); +#elif defined(OPENVINO_CPP_VER_AT_LEAST_17) + EXPECT_EQ(std::string(""), ov::util::Path(L"").u8string()); + EXPECT_EQ(std::string("file.txt"), ov::util::Path(L"file.txt").u8string()); + EXPECT_EQ(std::string("./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_EQ(std::string("~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_EQ(std::string("/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); +#endif +} + #if (!defined(_MSC_VER) && !(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ !(defined(__clang__) && __clang_major__ < 17)) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to From 567e37eb2d896ba59912ba30b65942e2dd35ce4d Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 9 Jan 2025 18:57:14 +0100 Subject: [PATCH 43/66] test wstring cast only on newer compiler --- src/core/tests/file_util.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index afb4739d6d3047..029086c4a20fd6 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -388,14 +388,26 @@ TEST(file_util, path_cast_from_wstring_to_char8_t) { EXPECT_EQ(std::u8string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); EXPECT_EQ(std::u8string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); EXPECT_EQ(std::u8string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); - EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); #elif defined(OPENVINO_CPP_VER_AT_LEAST_17) EXPECT_EQ(std::string(""), ov::util::Path(L"").u8string()); EXPECT_EQ(std::string("file.txt"), ov::util::Path(L"file.txt").u8string()); EXPECT_EQ(std::string("./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); EXPECT_EQ(std::string("~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); EXPECT_EQ(std::string("/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); +#endif +} + +TEST(file_util, unicode_path_cast_from_wstring_to_char8_t) { + // from wchar_t to char8_t +#if defined(OPENVINO_CPP_VER_AT_LEAST_20) && \ + (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ + !(defined(__clang__) && __clang_major__ < 17)) + EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); + +#elif defined(OPENVINO_CPP_VER_AT_LEAST_17) && \ + (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ + !(defined(__clang__) && __clang_major__ < 17)) EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); #endif From 5aac7b8b05267ab57752d2679383b2b1f1a0b49b Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 9 Jan 2025 23:46:10 +0100 Subject: [PATCH 44/66] add macro for readability --- src/core/tests/file_util.cpp | 52 +++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 029086c4a20fd6..54f79384b919f3 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -276,7 +276,19 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); } +#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) +# define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 +#endif + +#if !(defined(__clang__) || __clang_major__ >= 17) +# define CLANG_NOT_USED_OR_VER_AT_LEAST_17 +#endif + #if !defined(_MSC_VER) +# define MSVC_NOT_USED +#endif + +#if defined(MSVC_NOT_USED) TEST(file_util, path_cast_unicode_msc_skip) { EXPECT_EQ("/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", ov::util::Path(u8"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); @@ -339,8 +351,7 @@ TEST(file_util, path_cast_to_u32string) { } #endif -#if (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17)) +#if defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath @@ -362,13 +373,13 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_wstring().c_str()); // from wchar_t to char16_t - EXPECT_EQ(u"", ov::util::Path(L"").u16string()); - EXPECT_EQ(u"file.txt", ov::util::Path(L"file.txt").u16string()); - EXPECT_EQ(u"./local/file.txt", ov::util::Path(L"./local/file.txt").generic_u16string()); - EXPECT_EQ(u"~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_u16string()); - EXPECT_EQ(u"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"") == ov::util::Path(L"").u16string()); + EXPECT_TRUE(std::u16string(u"file.txt") == ov::util::Path(L"file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"./local/file.txt") == ov::util::Path(L"./local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").generic_u16string()); } TEST(file_util, path_cast_to_wstring) { @@ -399,22 +410,19 @@ TEST(file_util, path_cast_from_wstring_to_char8_t) { TEST(file_util, unicode_path_cast_from_wstring_to_char8_t) { // from wchar_t to char8_t -#if defined(OPENVINO_CPP_VER_AT_LEAST_20) && \ - (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17)) - EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); - -#elif defined(OPENVINO_CPP_VER_AT_LEAST_17) && \ - (!(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17)) - EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt"), - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").generic_u8string()); +#if defined(OPENVINO_CPP_VER_AT_LEAST_20) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && \ + defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) + EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt"), + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt").generic_u8string()); + +#elif defined(OPENVINO_CPP_VER_AT_LEAST_17) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && \ + defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_2.txt").generic_u8string()); #endif } -#if (!defined(_MSC_VER) && !(defined(__GNUC__) && (__GNUC__ < 12 || __GNUC__ == 12 && __GNUC_MINOR__ < 3)) && \ - !(defined(__clang__) && __clang_major__ < 17)) +#if defined(MSVC_NOT_USED) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 From ca179e536456c96880aa4df3198e286e3bf55586 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 00:05:08 +0100 Subject: [PATCH 45/66] fix macro --- src/core/tests/file_util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 54f79384b919f3..b79205fbf09014 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -276,11 +276,11 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); } -#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)) +#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) # define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 #endif -#if !(defined(__clang__) || __clang_major__ >= 17) +#if !defined(__clang__) || defined(__clang__) && __clang_major__ >= 17 # define CLANG_NOT_USED_OR_VER_AT_LEAST_17 #endif @@ -290,8 +290,8 @@ TEST(file_util, path_cast_unicode) { #if defined(MSVC_NOT_USED) TEST(file_util, path_cast_unicode_msc_skip) { - EXPECT_EQ("/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", - ov::util::Path(u8"/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); + EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", // ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", From 486aad2b6c836d548484fa35a167e03b03228386 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 00:58:26 +0100 Subject: [PATCH 46/66] use filesystem include at msvc c++20 --- src/common/util/include/openvino/util/filesystem.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index cf48cc561de2da..f06788bfad4a61 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -6,7 +6,9 @@ #include "openvino/util/cpp_version.hpp" -#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_11) +#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) +# define OPENVINO_HAS_FILESYSTEM +#elif defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_11) # define OPENVINO_HAS_EXP_FILESYSTEM # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM From 31a1f0363bad7b9649b2710dea2a78a7dc51ea76 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 10:08:27 +0100 Subject: [PATCH 47/66] fix filesystem include --- src/common/util/include/openvino/util/filesystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index f06788bfad4a61..1b88d4e74e976c 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -13,7 +13,7 @@ # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM #elif defined(__has_include) -# if defined(OPENVINO_CPP_VER_AT_LEAST_17) && (__has_include()) && (!__has_include()) +# if defined(OPENVINO_CPP_VER_AT_LEAST_17) && (__has_include()) # define OPENVINO_HAS_FILESYSTEM # elif defined(OPENVINO_CPP_VER_AT_LEAST_11) && (__has_include()) # define OPENVINO_HAS_EXP_FILESYSTEM From e35b64e9409aa194ddf94b9b294a556b568fc08e Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 10:47:27 +0100 Subject: [PATCH 48/66] use EXPECT_TRUE instead EXPECT_EQ --- src/core/tests/file_util.cpp | 188 ++++++++++++++++++----------------- 1 file changed, 98 insertions(+), 90 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index b79205fbf09014..180c157fe9ae82 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -230,36 +230,36 @@ TEST(file_util, path_cast) { EXPECT_STREQ(L"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").generic_wstring().c_str()); // from char to u16string - EXPECT_EQ(std::u16string(u""), ov::util::Path("").u16string()); - EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path("file.txt").u16string()); - EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path("./local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path("~/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path("/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path("C:\\Users\\file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"") == ov::util::Path("").u16string()); + EXPECT_TRUE(std::u16string(u"file.txt") == ov::util::Path("file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"./local/file.txt") == ov::util::Path("./local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/local/file.txt") == ov::util::Path("~/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"/usr/local/file.txt") == ov::util::Path("/usr/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"C:\\Users\\file.txt") == ov::util::Path("C:\\Users\\file.txt").u16string()); // from char8_t to u16string - EXPECT_EQ(std::u16string(u""), ov::util::Path(u8"").u16string()); - EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path(u8"file.txt").u16string()); - EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path(u8"./local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path(u8"~/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path(u8"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path(u8"C:\\Users\\file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"") == ov::util::Path(u8"").u16string()); + EXPECT_TRUE(std::u16string(u"file.txt") == ov::util::Path(u8"file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"./local/file.txt") == ov::util::Path(u8"./local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/local/file.txt") == ov::util::Path(u8"~/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"/usr/local/file.txt") == ov::util::Path(u8"/usr/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"C:\\Users\\file.txt") == ov::util::Path(u8"C:\\Users\\file.txt").u16string()); // from char16_t to u16string - EXPECT_EQ(std::u16string(u""), ov::util::Path(u"").u16string()); - EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path(u"file.txt").u16string()); - EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path(u"./local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path(u"~/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path(u"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path(u"C:\\Users\\file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"") == ov::util::Path(u"").u16string()); + EXPECT_TRUE(std::u16string(u"file.txt") == ov::util::Path(u"file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"./local/file.txt") == ov::util::Path(u"./local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/local/file.txt") == ov::util::Path(u"~/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"/usr/local/file.txt") == ov::util::Path(u"/usr/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"C:\\Users\\file.txt") == ov::util::Path(u"C:\\Users\\file.txt").u16string()); // from char32_t to u16string - EXPECT_EQ(std::u16string(u""), ov::util::Path(U"").u16string()); - EXPECT_EQ(std::u16string(u"file.txt"), ov::util::Path(U"file.txt").u16string()); - EXPECT_EQ(std::u16string(u"./local/file.txt"), ov::util::Path(U"./local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"~/local/file.txt"), ov::util::Path(U"~/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"/usr/local/file.txt"), ov::util::Path(U"/usr/local/file.txt").generic_u16string()); - EXPECT_EQ(std::u16string(u"C:\\Users\\file.txt"), ov::util::Path(U"C:\\Users\\file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"") == ov::util::Path(U"").u16string()); + EXPECT_TRUE(std::u16string(u"file.txt") == ov::util::Path(U"file.txt").u16string()); + EXPECT_TRUE(std::u16string(u"./local/file.txt") == ov::util::Path(U"./local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/local/file.txt") == ov::util::Path(U"~/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"/usr/local/file.txt") == ov::util::Path(U"/usr/local/file.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u16string()); } TEST(file_util, path_cast_unicode) { @@ -268,12 +268,12 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); // from char, char8_t, char16_t, char32_t to u16string - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt") == + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); } #if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) @@ -288,68 +288,75 @@ TEST(file_util, path_cast_unicode) { # define MSVC_NOT_USED #endif -#if defined(MSVC_NOT_USED) TEST(file_util, path_cast_unicode_msc_skip) { - EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", + EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt"), ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); - // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - // ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); - // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt", - // ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); - // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt", - // ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); - // EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt", - // ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); - EXPECT_EQ(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); + + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt") == + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); + + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); } // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function TEST(file_util, path_cast_to_u32string) { // from char to u32string - EXPECT_EQ(std::u32string(U""), ov::util::Path("").u32string()); - EXPECT_EQ(std::u32string(U"file.txt"), ov::util::Path("file.txt").u32string()); - EXPECT_EQ(std::u32string(U"./local/file.txt"), ov::util::Path("./local/file.txt").u32string()); - EXPECT_EQ(std::u32string(U"~/local/file.txt"), ov::util::Path("~/local/file.txt").u32string()); - EXPECT_EQ(std::u32string(U"/usr/local/file.txt"), ov::util::Path("/usr/local/file.txt").u32string()); - EXPECT_EQ(std::u32string(U"C:\\Users\\file.txt"), ov::util::Path("C:\\Users\\file.txt").u32string()); - EXPECT_EQ(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt"), - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); + EXPECT_TRUE(std::u32string(U"") == ov::util::Path("").u32string()); + EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path("file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path("./local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path("~/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path("/usr/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path("C:\\Users\\file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); // from char8_t to u32string - EXPECT_EQ(U"", ov::util::Path(u8"").u32string()); - EXPECT_EQ(U"file.txt", ov::util::Path(u8"file.txt").u32string()); - EXPECT_EQ(U"./local/file.txt", ov::util::Path(u8"./local/file.txt").u32string()); - EXPECT_EQ(U"~/local/file.txt", ov::util::Path(u8"~/local/file.txt").u32string()); - EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u8"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u8"C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").u32string()); + EXPECT_TRUE(std::u32string(U"") == ov::util::Path(u8"").u32string()); + EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(u8"file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(u8"./local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(u8"~/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(u8"/usr/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(u8"C:\\Users\\file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").u32string()); // from char16_t to u32string - EXPECT_EQ(U"", ov::util::Path(u"").u32string()); - EXPECT_EQ(U"file.txt", ov::util::Path(u"file.txt").u32string()); - EXPECT_EQ(U"./local/file.txt", ov::util::Path(u"./local/file.txt").u32string()); - EXPECT_EQ(U"~/local/file.txt", ov::util::Path(u"~/local/file.txt").u32string()); - EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(u"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(u"C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt").u32string()); + EXPECT_TRUE(std::u32string(U"") == ov::util::Path(u"").u32string()); + EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(u"file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(u"./local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(u"~/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(u"/usr/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(u"C:\\Users\\file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt").u32string()); // from char32_t to u32string - EXPECT_EQ(U"", ov::util::Path(U"").u32string()); - EXPECT_EQ(U"file.txt", ov::util::Path(U"file.txt").u32string()); - EXPECT_EQ(U"./local/file.txt", ov::util::Path(U"./local/file.txt").u32string()); - EXPECT_EQ(U"~/local/file.txt", ov::util::Path(U"~/local/file.txt").u32string()); - EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(U"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"C:\\Users\\file.txt", ov::util::Path(U"C:\\Users\\file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").u32string()); + EXPECT_TRUE(std::u32string(U"") == ov::util::Path(U"").u32string()); + EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(U"file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(U"./local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(U"~/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(U"/usr/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt") == + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").u32string()); // from char, char8_t, char16_t, char32_t to u32string - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt", ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt") == + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); } -#endif #if defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 @@ -394,11 +401,11 @@ TEST(file_util, path_cast_to_wstring) { TEST(file_util, path_cast_from_wstring_to_char8_t) { // from wchar_t to char8_t #if defined(OPENVINO_CPP_VER_AT_LEAST_20) - EXPECT_EQ(std::u8string(u8""), ov::util::Path(L"").u8string()); - EXPECT_EQ(std::u8string(u8"file.txt"), ov::util::Path(L"file.txt").u8string()); - EXPECT_EQ(std::u8string(u8"./local/file.txt"), ov::util::Path(L"./local/file.txt").generic_u8string()); - EXPECT_EQ(std::u8string(u8"~/local/file.txt"), ov::util::Path(L"~/local/file.txt").generic_u8string()); - EXPECT_EQ(std::u8string(u8"/usr/local/file.txt"), ov::util::Path(L"/usr/local/file.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"") == ov::util::Path(L"").u8string()); + EXPECT_TRUE(std::u8string(u8"file.txt") == ov::util::Path(L"file.txt").u8string()); + EXPECT_TRUE(std::u8string(u8"./local/file.txt") == ov::util::Path(L"./local/file.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").generic_u8string()); #elif defined(OPENVINO_CPP_VER_AT_LEAST_17) EXPECT_EQ(std::string(""), ov::util::Path(L"").u8string()); EXPECT_EQ(std::string("file.txt"), ov::util::Path(L"file.txt").u8string()); @@ -412,8 +419,8 @@ TEST(file_util, unicode_path_cast_from_wstring_to_char8_t) { // from wchar_t to char8_t #if defined(OPENVINO_CPP_VER_AT_LEAST_20) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && \ defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) - EXPECT_EQ(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt"), - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt").generic_u8string()); #elif defined(OPENVINO_CPP_VER_AT_LEAST_17) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && \ defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) @@ -422,19 +429,20 @@ TEST(file_util, unicode_path_cast_from_wstring_to_char8_t) { #endif } -#if defined(MSVC_NOT_USED) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) +#if defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath TEST(file_util, path_cast_from_wstring_to_u32string) { - EXPECT_EQ(U"", ov::util::Path(L"").u32string()); - EXPECT_EQ(U"file.txt", ov::util::Path(L"file.txt").u32string()); - EXPECT_EQ(U"./local/file.txt", ov::util::Path(L"./local/file.txt").u32string()); - EXPECT_EQ(U"~/local/file.txt", ov::util::Path(L"~/local/file.txt").u32string()); - EXPECT_EQ(U"/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").u32string()); - EXPECT_EQ(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").u32string()); + EXPECT_TRUE(std::u32string(U"") == ov::util::Path(L"").u32string()); + EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(L"file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(L"./local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").u32string()); } TEST(file_util, path_cast_to_wstring_msc_skip) { From 218bb2f56945e1c1c25e36c1c48047e2dd62a28f Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 11:36:21 +0100 Subject: [PATCH 49/66] use std::u8string only with c++20 --- src/core/tests/file_util.cpp | 43 +++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 180c157fe9ae82..b404c9581c18f5 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -266,6 +266,8 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); + EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); // from char, char8_t, char16_t, char32_t to u16string EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt") == @@ -274,24 +276,10 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); -} - -#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) -# define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 -#endif - -#if !defined(__clang__) || defined(__clang__) && __clang_major__ >= 17 -# define CLANG_NOT_USED_OR_VER_AT_LEAST_17 -#endif - -#if !defined(_MSC_VER) -# define MSVC_NOT_USED -#endif - -TEST(file_util, path_cast_unicode_msc_skip) { - EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt"), - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); +#if defined(OPENVINO_CPP_VER_AT_LEAST_20) EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == @@ -300,9 +288,16 @@ TEST(file_util, path_cast_unicode_msc_skip) { ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt") == ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); - - EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); +#elif defined(OPENVINO_CPP_VER_AT_LEAST_17) + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt"), + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt"), + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt"), + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt"), + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); +#endif } // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function @@ -358,6 +353,14 @@ TEST(file_util, path_cast_to_u32string) { ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); } +#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) +# define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 +#endif + +#if !defined(__clang__) || defined(__clang__) && __clang_major__ >= 17 +# define CLANG_NOT_USED_OR_VER_AT_LEAST_17 +#endif + #if defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath From 2fcd2c8fdce5732b498840429d6f4729b37159de Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 11:48:18 +0100 Subject: [PATCH 50/66] refactor --- src/core/tests/file_util.cpp | 47 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index b404c9581c18f5..e83f6774ebdcc8 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -398,6 +398,27 @@ TEST(file_util, path_cast_to_wstring) { ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").generic_wstring().c_str()); EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_wstring().c_str()); + + // from char8_t, char16_t to wchar_t + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").wstring().c_str()); +} + +// error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to +// reference a deleted function +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 +// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath + +TEST(file_util, path_cast_from_wstring_to_u32string) { + EXPECT_TRUE(std::u32string(U"") == ov::util::Path(L"").u32string()); + EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(L"file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(L"./local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").u32string()); } #endif @@ -431,29 +452,3 @@ TEST(file_util, unicode_path_cast_from_wstring_to_char8_t) { ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_2.txt").generic_u8string()); #endif } - -#if defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) -// error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to -// reference a deleted function -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 -// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath - -TEST(file_util, path_cast_from_wstring_to_u32string) { - EXPECT_TRUE(std::u32string(U"") == ov::util::Path(L"").u32string()); - EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(L"file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(L"./local/file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt") == - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").u32string()); -} - -TEST(file_util, path_cast_to_wstring_msc_skip) { - // from char8_t, char16_t to wchar_t - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").wstring().c_str()); -} - -#endif From ce0d2f25d8d149b4397976d592cbc9ed06dee8f5 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 11:48:43 +0100 Subject: [PATCH 51/66] add new sequence numbers --- src/core/tests/file_util.cpp | 114 +++++++++++++++++------------------ 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index e83f6774ebdcc8..e5ebc726cd52dd 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -266,37 +266,37 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); - EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_string()); + EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string()); // from char, char8_t, char16_t, char32_t to u16string + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt") == - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); - EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt") == - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u16string()); - EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u16string()); + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); #if defined(OPENVINO_CPP_VER_AT_LEAST_20) - EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); - EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); - EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt") == - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_u8string()); EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u8string()); #elif defined(OPENVINO_CPP_VER_AT_LEAST_17) - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt"), - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_u8string()); - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt"), - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u8string()); - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt"), - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u8string()); - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt"), - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt"), + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt"), + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt"), + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt").generic_u8string()); + EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt"), + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); #endif } // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to @@ -309,8 +309,8 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path("~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path("/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path("C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt").u32string()); // from char8_t to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path(u8"").u32string()); @@ -319,8 +319,8 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(u8"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(u8"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(u8"C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); // from char16_t to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path(u"").u32string()); @@ -329,8 +329,8 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(u"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(u"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(u"C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt") == - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); // from char32_t to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path(U"").u32string()); @@ -339,18 +339,18 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(U"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(U"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt") == - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").u32string()); - - // from char, char8_t, char16_t, char32_t to u32string - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt") == - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); + + // from char, char8_t, char16_t, char32_t to u32string + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt") == + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt") == + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").u32string()); } #if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) @@ -372,8 +372,8 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").generic_string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").generic_string().c_str()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_string().c_str()); // from wchar_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(L"").wstring().c_str()); @@ -388,22 +388,22 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_TRUE(std::u16string(u"./local/file.txt") == ov::util::Path(L"./local/file.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").generic_u16string()); - EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt") == - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").generic_u16string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").generic_u16string()); } TEST(file_util, path_cast_to_wstring) { // from char, char32_t to wchar_t - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").generic_wstring().c_str()); - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_wstring().c_str()); - - // from char8_t, char16_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").wstring().c_str()); + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring().c_str()); EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").wstring().c_str()); + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").generic_wstring().c_str()); + + // from char8_t, char16_t to wchar_t + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt").wstring().c_str()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗30.txt", + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗30.txt").wstring().c_str()); } // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to @@ -417,8 +417,8 @@ TEST(file_util, path_cast_from_wstring_to_u32string) { EXPECT_TRUE(std::u32string(U"./local/file.txt") == ov::util::Path(L"./local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(L"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(L"/usr/local/file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt") == - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗26.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗31.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗31.txt").u32string()); } #endif @@ -443,12 +443,12 @@ TEST(file_util, unicode_path_cast_from_wstring_to_char8_t) { // from wchar_t to char8_t #if defined(OPENVINO_CPP_VER_AT_LEAST_20) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && \ defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) - EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt") == - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_1.txt").generic_u8string()); + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗32.txt") == + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗32.txt").generic_u8string()); #elif defined(OPENVINO_CPP_VER_AT_LEAST_17) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && \ defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) - EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22_2.txt").generic_u8string()); + EXPECT_EQ(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗33.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗33.txt").generic_u8string()); #endif } From 8e464a4f9b3dc9f9fca7f585cb416570d6ddd7e8 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 14:06:17 +0100 Subject: [PATCH 52/66] skip windows pre c++20 tests with std::u32string --- src/core/tests/file_util.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index e5ebc726cd52dd..03ebf880ea1698 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -299,6 +299,8 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); #endif } + +#if !defined(_MSC_VER) || defined(OPENVINO_CPP_VER_AT_LEAST_20) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function TEST(file_util, path_cast_to_u32string) { @@ -352,6 +354,7 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").u32string()); } +#endif #if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) # define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 From 072d3e2785004720cb25deff9cf49e3f1564a261 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 14:10:40 +0100 Subject: [PATCH 53/66] do not use experimental with msvc c++17 --- src/common/util/include/openvino/util/filesystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp index 1b88d4e74e976c..d01b00d3386efa 100644 --- a/src/common/util/include/openvino/util/filesystem.hpp +++ b/src/common/util/include/openvino/util/filesystem.hpp @@ -6,7 +6,7 @@ #include "openvino/util/cpp_version.hpp" -#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) +#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_17) # define OPENVINO_HAS_FILESYSTEM #elif defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_11) # define OPENVINO_HAS_EXP_FILESYSTEM From 71c9804952c52bcfe11f23eb463a8477981038c5 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 10 Jan 2025 14:11:35 +0100 Subject: [PATCH 54/66] Revert "skip windows pre c++20 tests with std::u32string" This reverts commit 8e464a4f9b3dc9f9fca7f585cb416570d6ddd7e8. --- src/core/tests/file_util.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 03ebf880ea1698..e5ebc726cd52dd 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -299,8 +299,6 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); #endif } - -#if !defined(_MSC_VER) || defined(OPENVINO_CPP_VER_AT_LEAST_20) // error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to // reference a deleted function TEST(file_util, path_cast_to_u32string) { @@ -354,7 +352,6 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").u32string()); } -#endif #if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) # define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 From 540e921ef1f6926abd197246b092cf3cacddc405 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 10 Jan 2025 17:21:15 +0000 Subject: [PATCH 55/66] skip test with u8 ctor unocode path for msvc c++17 --- src/core/tests/file_util.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index e5ebc726cd52dd..f8e6cbfec7fcbd 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -266,8 +266,6 @@ TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); - EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string()); // from char, char8_t, char16_t, char32_t to u16string EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == @@ -276,8 +274,6 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); - EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); #if defined(OPENVINO_CPP_VER_AT_LEAST_20) EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt") == @@ -295,12 +291,24 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").generic_u8string()); EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt"), ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt").generic_u8string()); +#endif + +#if !defined(_MSC_VER) || defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); + EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt"), + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string()); EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt"), ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").u32string()); + EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt", + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt").wstring().c_str()); #endif } -// error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to -// reference a deleted function + TEST(file_util, path_cast_to_u32string) { // from char to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path("").u32string()); @@ -319,8 +327,6 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(u8"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(u8"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(u8"C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); // from char16_t to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path(u"").u32string()); @@ -342,11 +348,9 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); - // from char, char8_t, char16_t, char32_t to u32string + // from char, char16_t, char32_t to u32string EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").u32string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt") == ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").u32string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt") == @@ -393,15 +397,12 @@ TEST(file_util, path_cast_from_wstring) { } TEST(file_util, path_cast_to_wstring) { - // from char, char32_t to wchar_t + // from char, char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring().c_str()); EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").generic_wstring().c_str()); - // from char8_t, char16_t to wchar_t - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt").wstring().c_str()); EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗30.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗30.txt").wstring().c_str()); } From aff4ebcf952cbb293b198a265d3658f1d3e25bf6 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Sat, 11 Jan 2025 20:00:59 +0100 Subject: [PATCH 56/66] delete duplicate test --- src/core/tests/file_util.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index f8e6cbfec7fcbd..09db8d0a2c3862 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -298,14 +298,16 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt"), ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string()); - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt"), - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt") == - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗22.txt").u32string()); - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt", - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt").wstring().c_str()); +#endif + +#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) || \ + !defined(_MSC_VER) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) + EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); + EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt") == + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt").wstring()); #endif } From 255e0463b7a313e7b60565307909e424ce52d7ea Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 07:43:47 +0100 Subject: [PATCH 57/66] remove duplicate test --- src/core/tests/file_util.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 09db8d0a2c3862..378dfc737ff9bf 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -262,6 +262,14 @@ TEST(file_util, path_cast) { EXPECT_TRUE(std::u16string(u"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u16string()); } +#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) +# define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 +#endif + +#if !defined(__clang__) || defined(__clang__) && __clang_major__ >= 17 +# define CLANG_NOT_USED_OR_VER_AT_LEAST_17 +#endif + TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string()); EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); @@ -319,8 +327,6 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path("~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path("/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path("C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗17.txt").u32string()); // from char8_t to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path(u8"").u32string()); @@ -337,8 +343,6 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(u"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(u"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(u"C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt") == - ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗19.txt").u32string()); // from char32_t to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path(U"").u32string()); @@ -347,8 +351,6 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"~/local/file.txt") == ov::util::Path(U"~/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(U"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u32string()); - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt") == - ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗20.txt").u32string()); // from char, char16_t, char32_t to u32string EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt") == @@ -359,14 +361,6 @@ TEST(file_util, path_cast_to_u32string) { ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt").u32string()); } -#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) -# define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 -#endif - -#if !defined(__clang__) || defined(__clang__) && __clang_major__ >= 17 -# define CLANG_NOT_USED_OR_VER_AT_LEAST_17 -#endif - #if defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath From d6379b25bea0f0f83ebdb1574f3c287dc2edc01e Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 09:51:44 +0100 Subject: [PATCH 58/66] turn off failing windows test --- src/core/tests/file_util.cpp | 40 +++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 378dfc737ff9bf..38a2be6ad99fe5 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -272,12 +272,6 @@ TEST(file_util, path_cast) { TEST(file_util, path_cast_unicode) { EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt", ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗1.txt").generic_string()); - EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt", ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); - EXPECT_EQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); - - // from char, char8_t, char16_t, char32_t to u16string - EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt") == ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗6.txt").generic_u16string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt") == @@ -293,8 +287,6 @@ TEST(file_util, path_cast_unicode) { EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt") == ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗12.txt").generic_u8string()); #elif defined(OPENVINO_CPP_VER_AT_LEAST_17) - EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt"), - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").generic_u8string()); EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt"), ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗14.txt").generic_u8string()); EXPECT_EQ(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗15.txt"), @@ -319,6 +311,28 @@ TEST(file_util, path_cast_unicode) { #endif } +#if !defined(_MSC_VER) +TEST(file_util, path_cast_unicode_form_string) { + EXPECT_TRUE(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").generic_u8string()); + EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u16string()); + EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").u32string()); + EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring()); +} + +TEST(file_util, path_cast_unicode_to_string) { + EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt"), + ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); + EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt"), + ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); + EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", + ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_string().c_str()); +} +#endif + TEST(file_util, path_cast_to_u32string) { // from char to u32string EXPECT_TRUE(std::u32string(U"") == ov::util::Path("").u32string()); @@ -352,9 +366,7 @@ TEST(file_util, path_cast_to_u32string) { EXPECT_TRUE(std::u32string(U"/usr/local/file.txt") == ov::util::Path(U"/usr/local/file.txt").u32string()); EXPECT_TRUE(std::u32string(U"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u32string()); - // from char, char16_t, char32_t to u32string - EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").u32string()); + // from char16_t, char32_t to u32string EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt") == ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗23.txt").u32string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗24.txt") == @@ -372,8 +384,6 @@ TEST(file_util, path_cast_from_wstring) { EXPECT_STREQ("./local/file.txt", ov::util::Path(L"./local/file.txt").generic_string().c_str()); EXPECT_STREQ("~/local/file.txt", ov::util::Path(L"~/local/file.txt").generic_string().c_str()); EXPECT_STREQ("/usr/local/file.txt", ov::util::Path(L"/usr/local/file.txt").generic_string().c_str()); - EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", - ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_string().c_str()); // from wchar_t to wchar_t EXPECT_STREQ(L"", ov::util::Path(L"").wstring().c_str()); @@ -393,9 +403,7 @@ TEST(file_util, path_cast_from_wstring) { } TEST(file_util, path_cast_to_wstring) { - // from char, char16_t, char32_t to wchar_t - EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt", - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring().c_str()); + // from char16_t, char32_t to wchar_t EXPECT_STREQ(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt", ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗28.txt").generic_wstring().c_str()); From fd5e21a0132a317fdf15c7f3d97b39af173bbba8 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 13 Jan 2025 09:18:44 +0000 Subject: [PATCH 59/66] skip wstring unicode cast on older gcc compiler --- src/core/tests/file_util.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 38a2be6ad99fe5..47e422312e0e63 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -312,15 +312,13 @@ TEST(file_util, path_cast_unicode) { } #if !defined(_MSC_VER) -TEST(file_util, path_cast_unicode_form_string) { +TEST(file_util, path_cast_unicode_from_string) { EXPECT_TRUE(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").generic_u8string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u16string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗21.txt").u32string()); - EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt") == - ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring()); } TEST(file_util, path_cast_unicode_to_string) { @@ -328,6 +326,15 @@ TEST(file_util, path_cast_unicode_to_string) { ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt"), ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt").generic_string()); +} +#endif + +#if !defined(_MSC_VER) && GCC_NOT_USED_OR_VERSION_AT_LEAST_12_3 && CLANG_NOT_USED_OR_VERSION_AT_LEAST_17 +TEST(file_util, path_cast_unicode_from_string_to_wstring) { + EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt") == + ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring()); +} +TEST(file_util, path_cast_unicode_from_wstring_to_string) { EXPECT_STREQ("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt", ov::util::Path(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗25.txt").generic_string().c_str()); } From dbaec1de821d035fdd5b42863c592f49a4659036 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 13 Jan 2025 10:13:50 +0000 Subject: [PATCH 60/66] macro rename --- src/core/tests/file_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 47e422312e0e63..1ac0ed2497baa3 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -329,7 +329,7 @@ TEST(file_util, path_cast_unicode_to_string) { } #endif -#if !defined(_MSC_VER) && GCC_NOT_USED_OR_VERSION_AT_LEAST_12_3 && CLANG_NOT_USED_OR_VERSION_AT_LEAST_17 +#if !defined(_MSC_VER) && GCC_NOT_USED_OR_VER_AT_LEAST_12_3 && CLANG_NOT_USED_OR_VER_AT_LEAST_17 TEST(file_util, path_cast_unicode_from_string_to_wstring) { EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring()); From c504ea3c6cbc5d32f0cca8ce3fcd6eda94b3ec63 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 13 Jan 2025 10:27:54 +0000 Subject: [PATCH 61/66] fix macro check --- src/core/tests/file_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 1ac0ed2497baa3..093cf8b4a0e31c 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -329,7 +329,7 @@ TEST(file_util, path_cast_unicode_to_string) { } #endif -#if !defined(_MSC_VER) && GCC_NOT_USED_OR_VER_AT_LEAST_12_3 && CLANG_NOT_USED_OR_VER_AT_LEAST_17 +#if !defined(_MSC_VER) && !defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && !defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) TEST(file_util, path_cast_unicode_from_string_to_wstring) { EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring()); From 3cbc2d22750d051f9857205a07353be96152b399 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 12:41:50 +0100 Subject: [PATCH 62/66] skip windows test string path to unocode cast --- src/core/tests/file_util.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 093cf8b4a0e31c..172cedc8bba6ac 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -262,6 +262,10 @@ TEST(file_util, path_cast) { EXPECT_TRUE(std::u16string(u"C:\\Users\\file.txt") == ov::util::Path(U"C:\\Users\\file.txt").u16string()); } +// There are known issues related with usage of std::filesystem::path unocode represenataion: +// https://jira.devtools.intel.com/browse/CVS-160477 +// * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 +// * https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath #if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3) # define GCC_NOT_USED_OR_VER_AT_LEAST_12_3 #endif @@ -277,9 +281,11 @@ TEST(file_util, path_cast_unicode) { EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt") == ov::util::Path(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗7.txt").generic_u16string()); -#if defined(OPENVINO_CPP_VER_AT_LEAST_20) +#if !defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗9.txt").generic_u8string()); +#endif +#if defined(OPENVINO_CPP_VER_AT_LEAST_20) EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt") == ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗10.txt").generic_u8string()); EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗11.txt") == @@ -330,6 +336,9 @@ TEST(file_util, path_cast_unicode_to_string) { #endif #if !defined(_MSC_VER) && !defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && !defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 +// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath + TEST(file_util, path_cast_unicode_from_string_to_wstring) { EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗27.txt").generic_wstring()); @@ -418,11 +427,6 @@ TEST(file_util, path_cast_to_wstring) { ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗30.txt").wstring().c_str()); } -// error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to -// reference a deleted function -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 -// https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath - TEST(file_util, path_cast_from_wstring_to_u32string) { EXPECT_TRUE(std::u32string(U"") == ov::util::Path(L"").u32string()); EXPECT_TRUE(std::u32string(U"file.txt") == ov::util::Path(L"file.txt").u32string()); From 02d5593b57af2a95614cd3c0878bf1bd71802d69 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 14:44:41 +0100 Subject: [PATCH 63/66] use bare u8 string literal --- src/core/tests/file_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 172cedc8bba6ac..f6a68548896441 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -319,7 +319,7 @@ TEST(file_util, path_cast_unicode) { #if !defined(_MSC_VER) TEST(file_util, path_cast_unicode_from_string) { - EXPECT_TRUE(std::string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt") == + EXPECT_TRUE(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt" == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗13.txt").generic_u8string()); EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt") == ov::util::Path("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗5.txt").generic_u16string()); From 9178289628aa58408879162b9358f81fb83d342d Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 15:15:59 +0100 Subject: [PATCH 64/66] skip test for windows --- src/core/tests/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index f6a68548896441..fd5fe45a3aa557 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -302,8 +302,6 @@ TEST(file_util, path_cast_unicode) { #if !defined(_MSC_VER) || defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) EXPECT_TRUE(std::u16string(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt") == ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗8.txt").generic_u16string()); - EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt"), - ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string()); EXPECT_TRUE(std::u32string(U"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt") == ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); #endif @@ -328,6 +326,8 @@ TEST(file_util, path_cast_unicode_from_string) { } TEST(file_util, path_cast_unicode_to_string) { + EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt"), + ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗4.txt").generic_string()); EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt"), ov::util::Path(u"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗2.txt").generic_string()); EXPECT_EQ(std::string("~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗3.txt"), From a5e40bdf41bbb46de916371a6d98b3a60af7a985 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 22:43:07 +0100 Subject: [PATCH 65/66] fix macro check --- src/core/tests/file_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index fdfc645a4052fe..42bf046ade78ff 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -335,7 +335,7 @@ TEST(file_util, path_cast_unicode_to_string) { } #endif -#if !defined(_MSC_VER) && !defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && !defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) +#if !defined(_MSC_VER) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048 // https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath From 0b3be4759219153be94959be3e95ca54878fe04e Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Mon, 13 Jan 2025 23:32:28 +0100 Subject: [PATCH 66/66] testo only with c++20 --- src/core/tests/file_util.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 42bf046ade78ff..33d5d7f9db2896 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -306,8 +306,9 @@ TEST(file_util, path_cast_unicode) { ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗18.txt").u32string()); #endif -#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_20) || \ - !defined(_MSC_VER) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17) +#if defined(OPENVINO_CPP_VER_AT_LEAST_20) && \ + (defined(_MSC_VER) || \ + !defined(_MSC_VER) && defined(GCC_NOT_USED_OR_VER_AT_LEAST_12_3) && defined(CLANG_NOT_USED_OR_VER_AT_LEAST_17)) EXPECT_TRUE(std::u8string(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt") == ov::util::Path(u8"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗16.txt").generic_u8string()); EXPECT_TRUE(std::wstring(L"~/狗/ǡ୫ԩϗ/にほ/ąę/ど/௸ඊƷ/狗29.txt") ==