Skip to content

Commit 410c0cb

Browse files
committed
Add test for ov::util::create_directory_recursive
Signed-off-by: Raasz, Pawel <[email protected]>
1 parent bb0b4ea commit 410c0cb

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

src/tests/test_utils/common_test_utils/tests/file_util_test.cpp

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5-
#include "openvino/util/file_util.hpp"
6-
75
#include <gtest/gtest.h>
86

97
#include <random>
108
#include <sstream>
119
#include <string>
1210
#include <string_view>
11+
#include <variant>
1312
#include <vector>
1413

14+
#include "common_test_utils/common_utils.hpp"
15+
#include "common_test_utils/file_utils.hpp"
1516
#include "openvino/core/visibility.hpp"
1617
#include "openvino/util/file_path.hpp"
18+
#include "openvino/util/file_util.hpp"
1719

1820
namespace ov::test {
1921
using std::string;
@@ -633,4 +635,51 @@ TEST_F(FileUtilTest, androidWithCutFileSizeTest) {
633635
EXPECT_EQ(ov::util::file_size(ov::util::Path("android_test_file_20.txt!_to_cut.jar")), 20);
634636
}
635637
#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+
}
636685
} // namespace ov::test

0 commit comments

Comments
 (0)