Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

OV file path definition #27954

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9fdc9a5
Add include path for core/visibility to cmake
barnasm1 Dec 4, 2024
546897e
std::fs::path alias
barnasm1 Dec 4, 2024
7d0f218
improve includes and Path alias definition
barnasm1 Dec 5, 2024
d46f60e
add tests
barnasm1 Dec 6, 2024
d3c4b21
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 6, 2024
86f602e
code foramt
barnasm1 Dec 6, 2024
3770a18
revert cmake, move OPENVINO_CPP_VER from visability to util
barnasm1 Dec 6, 2024
e82d54b
do not include util.hpp in visability.hpp
barnasm1 Dec 6, 2024
1f8d806
clean cpp version defines
barnasm1 Dec 6, 2024
4813a39
remove generic_string tests
barnasm1 Dec 6, 2024
242e396
apply new cpp version macro
barnasm1 Dec 6, 2024
2f696f5
remove all generic_*string tests
barnasm1 Dec 6, 2024
1b2b5e3
skip u32string cast in windows tests
barnasm1 Dec 6, 2024
14452c5
format
barnasm1 Dec 6, 2024
690a332
Merge branch 'master' into ov_file_path_definition
mlukasze Dec 9, 2024
fcf5378
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 9, 2024
9a788e9
restore visibility defines
barnasm1 Dec 9, 2024
dd2e225
skip u32string cast in windows tests, remove nested macro check
barnasm1 Dec 9, 2024
e476a25
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 9, 2024
29817d6
fix check
barnasm1 Dec 9, 2024
d8b6c6d
code format
barnasm1 Dec 9, 2024
43ff3b6
check define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
barnasm1 Dec 9, 2024
57e4524
add sequence number to easier debug
barnasm1 Dec 9, 2024
613495f
add Path doxy
barnasm1 Dec 9, 2024
e8de06a
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 9, 2024
ad5bbd7
Merge branch 'master' into ov_file_path_definition
mlukasze Dec 10, 2024
747559a
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 10, 2024
d8fde2e
refactor tests
barnasm1 Dec 10, 2024
5653440
Merge branch 'master' into ov_file_path_definition
mlukasze Dec 13, 2024
f6f3745
Merge branch 'master' into ov_file_path_definition
mlukasze Dec 16, 2024
f7178d5
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 17, 2024
39fd2c1
fix test + format
barnasm1 Dec 17, 2024
45fb8ad
unify windows path test
barnasm1 Dec 17, 2024
6357c41
unify windows path test2
barnasm1 Dec 17, 2024
a29dd2e
Merge branch 'master' into ov_file_path_definition
mlukasze Dec 18, 2024
0cac7fb
skip test cast form u8, u16 on windows platform
barnasm1 Dec 18, 2024
a40e38c
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 18, 2024
d455c0a
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 19, 2024
0b4850f
unify cpp version check define names
barnasm1 Dec 19, 2024
9349de1
set windows platform tests
barnasm1 Dec 19, 2024
7acd20b
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 19, 2024
d19a62d
Merge branch 'master' into ov_file_path_definition
mlukasze Dec 20, 2024
37dcda1
use EXPECT_EQ instead EXPECT_STREQ for u8
barnasm1 Dec 20, 2024
9f45244
fix test
barnasm1 Dec 20, 2024
bf0e7f0
fix path_cast_unicode test 4.txt
barnasm1 Dec 20, 2024
ef23b07
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 20, 2024
3dbce3a
skip test for mvs
barnasm1 Dec 20, 2024
548f44a
skip test for mvs2
barnasm1 Dec 20, 2024
2e50563
skip test
barnasm1 Dec 20, 2024
28a03c4
skip test2
barnasm1 Dec 20, 2024
61edd0c
skip all checks generic_u8string at test path_cast_unicode
barnasm1 Dec 20, 2024
7e4dad1
Merge branch 'master' into ov_file_path_definition
barnasm1 Dec 23, 2024
844c811
Merge branch 'master' into ov_file_path_definition
barnasm1 Jan 2, 2025
95e2f55
Merge branch 'master' into ov_file_path_definition
barnasm1 Jan 6, 2025
643ed07
Merge branch 'master' into ov_file_path_definition
mlukasze Jan 7, 2025
db91edd
Merge branch 'master' into ov_file_path_definition
barnasm1 Jan 7, 2025
cbb153d
use c_str cast at empty string tests
barnasm1 Jan 7, 2025
d0a56a9
revert use c_str cast at empty string tests
barnasm1 Jan 7, 2025
160394c
Merge branch 'master' into ov_file_path_definition
mlukasze Jan 8, 2025
4ef09e1
turn off failing tests
barnasm1 Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/common/util/include/openvino/util/cpp_version.hpp
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions src/common/util/include/openvino/util/file_path.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <cstdio>

#include "openvino/util/filesystem.hpp"
namespace ov {
namespace util {

#if defined(OPENVINO_HAS_FILESYSTEM)
barnasm1 marked this conversation as resolved.
Show resolved Hide resolved
using Path = std::filesystem::path;
#elif defined(OPENVINO_HAS_EXP_FILESYSTEM)
using Path = std::experimental::filesystem::path;
#endif

} // namespace util
} // namespace ov
16 changes: 7 additions & 9 deletions src/common/util/include/openvino/util/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@

#pragma once

#include "openvino/core/visibility.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(<filesystem>)) && (!__has_include(<experimental/filesystem>))
# if defined(OPENVINO_CPP_VER_AT_LEAST_17) && (__has_include(<filesystem>)) && (!__has_include(<experimental/filesystem>))
# define OPENVINO_HAS_FILESYSTEM
# elif defined(OPENVINO_CPP_VER_11) && (__has_include(<experimental/filesystem>))
# elif defined(OPENVINO_CPP_VER_AT_LEAST_11) && (__has_include(<experimental/filesystem>))
# define OPENVINO_HAS_EXP_FILESYSTEM
# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM
# endif
#endif

#if !defined(OPENVINO_HAS_FILESYSTEM) && !defined(OPENVINO_HAS_EXP_FILESYSTEM)
# error "Neither #include <filesystem> nor #include <experimental/filesystem> is available."
#elif defined(OPENVINO_HAS_FILESYSTEM)
#if defined(OPENVINO_HAS_FILESYSTEM)
# include <filesystem>
namespace std_fs = std::filesystem;
#elif defined(OPENVINO_HAS_EXP_FILESYSTEM)
# include <experimental/filesystem>
namespace std_fs = std::experimental::filesystem;
#else
# error "Neither #include <filesystem> nor #include <experimental/filesystem> is available."
#endif
28 changes: 0 additions & 28 deletions src/core/include/openvino/core/visibility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
mlukasze marked this conversation as resolved.
Show resolved Hide resolved
219 changes: 219 additions & 0 deletions src/core/tests/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <string>
#include <vector>

#include "openvino/util/file_path.hpp"

using namespace std;
using namespace ov;

Expand Down Expand Up @@ -167,3 +169,220 @@ 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);
}

barnasm1 marked this conversation as resolved.
Show resolved Hide resolved
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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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());

// 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
barnasm1 marked this conversation as resolved.
Show resolved Hide resolved
// 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());
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());

// 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());

// 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());

// 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());

// 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))
// 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());

// 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());

// 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());

// 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());

# 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());
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
}
Loading