|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
3 | 3 | //
|
4 | 4 |
|
5 |
| -#include "openvino/util/file_util.hpp" |
6 |
| - |
7 | 5 | #include <gtest/gtest.h>
|
8 | 6 |
|
9 | 7 | #include <random>
|
10 | 8 | #include <sstream>
|
11 | 9 | #include <string>
|
12 | 10 | #include <string_view>
|
| 11 | +#include <variant> |
13 | 12 | #include <vector>
|
14 | 13 |
|
| 14 | +#include "common_test_utils/common_utils.hpp" |
| 15 | +#include "common_test_utils/file_utils.hpp" |
15 | 16 | #include "openvino/core/visibility.hpp"
|
16 | 17 | #include "openvino/util/file_path.hpp"
|
| 18 | +#include "openvino/util/file_util.hpp" |
17 | 19 |
|
18 | 20 | namespace ov::test {
|
19 | 21 | using std::string;
|
@@ -633,4 +635,51 @@ TEST_F(FileUtilTest, androidWithCutFileSizeTest) {
|
633 | 635 | EXPECT_EQ(ov::util::file_size(ov::util::Path("android_test_file_20.txt!_to_cut.jar")), 20);
|
634 | 636 | }
|
635 | 637 | #endif
|
| 638 | + |
| 639 | +using StringPathVariantP = std::variant<std::string, std::u16string, std::u32string, std::wstring>; |
| 640 | + |
| 641 | +class FileUtilTestP : public FileUtilTest, public ::testing::WithParamInterface<StringPathVariantP> { |
| 642 | +protected: |
| 643 | + std::filesystem::path get_path_param() const { |
| 644 | + return std::visit( |
| 645 | + [](auto&& p) { |
| 646 | + return std::filesystem::path(p); |
| 647 | + }, |
| 648 | + GetParam()); |
| 649 | + } |
| 650 | +}; |
| 651 | + |
| 652 | +INSTANTIATE_TEST_SUITE_P(string_paths, |
| 653 | + FileUtilTestP, |
| 654 | + testing::Values("test_encoder/test_encoder.encrypted/", |
| 655 | + "test_encoder/test_encoder.encrypted")); |
| 656 | +INSTANTIATE_TEST_SUITE_P(u16_paths, |
| 657 | + FileUtilTestP, |
| 658 | + testing::Values(u"test_encoder/dot.folder", u"test_encoder/dot.folder/")); |
| 659 | + |
| 660 | +INSTANTIATE_TEST_SUITE_P(u32_paths, |
| 661 | + FileUtilTestP, |
| 662 | + testing::Values(U"test_encoder/dot.folder", U"test_encoder/dot.folder/")); |
| 663 | + |
| 664 | +INSTANTIATE_TEST_SUITE_P(wstring_paths, |
| 665 | + FileUtilTestP, |
| 666 | + testing::Values(L"test_encoder/test_encoder.encrypted", |
| 667 | + L"test_encoder/test_encoder.encrypted/")); |
| 668 | + |
| 669 | +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT |
| 670 | +INSTANTIATE_TEST_SUITE_P( |
| 671 | + unicode_paths, |
| 672 | + FileUtilTestP, |
| 673 | + testing::Values("这是.folder", L"这是_folder", L"这是_folder/", u"这是_folder/", U"这是_folder/")); |
| 674 | +#endif |
| 675 | + |
| 676 | +TEST_P(FileUtilTestP, create_directories) { |
| 677 | + const auto path = std::filesystem::path(utils::generateTestFilePrefix()) / get_path_param(); |
| 678 | + |
| 679 | + ov::util::create_directory_recursive(path); |
| 680 | + |
| 681 | + EXPECT_TRUE(utils::fileExists(path)); |
| 682 | + EXPECT_EQ(utils::removeDir(path.string()), 0); |
| 683 | + EXPECT_FALSE(utils::fileExists(path)); |
| 684 | +} |
636 | 685 | } // namespace ov::test
|
0 commit comments