MCPcopy Create free account
hub / github.com/catboost/catboost / TestCreateRemove

Method TestCreateRemove

util/system/fs_ut.cpp:37–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void TFsTest::TestCreateRemove() {
38 TFsPath dir1 = "dir_aбвг";
39 NFs::RemoveRecursive(dir1);
40 UNIT_ASSERT(!NFs::Exists(dir1));
41 UNIT_ASSERT(NFs::MakeDirectory(dir1));
42
43 UNIT_ASSERT(TFileStat(dir1).IsDir());
44 UNIT_ASSERT(!NFs::MakeDirectory(dir1));
45
46 UNIT_ASSERT(NFs::Exists(dir1));
47 TFsPath subdir1 = dir1 / "a" / "b";
48 // TFsPath link = dir1 / "link";
49
50 UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true));
51 UNIT_ASSERT(NFs::Exists(subdir1));
52 UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, false));
53 UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE));
54 UNIT_ASSERT_EXCEPTION(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true), TIoException);
55
56 TFsPath file1 = dir1 / "f1.txt";
57 TFsPath file2 = subdir1 + TString("_f2.txt");
58 TFsPath file3 = subdir1 / "f2.txt";
59 Touch(file1);
60 Touch(file2);
61 Touch(file3);
62 // UNIT_ASSERT(NFs::SymLink(file3.RealPath(), link));
63
64 UNIT_ASSERT(NFs::MakeDirectoryRecursive(dir1 / "subdir1" / "subdir2" / "subdir3" / "subdir4", NFs::FP_COMMON_FILE, false));
65 UNIT_ASSERT(NFs::MakeDirectoryRecursive(dir1 / "subdir1" / "subdir2", NFs::FP_COMMON_FILE, false));
66
67 // the target path is a file or "subdirectory" of a file
68 UNIT_ASSERT(!NFs::MakeDirectoryRecursive(file1 / "subdir1" / "subdir2", NFs::FP_COMMON_FILE, false));
69 UNIT_ASSERT(!NFs::MakeDirectoryRecursive(file1, NFs::FP_COMMON_FILE, false));
70
71 TString longUtf8Name = "";
72 while (longUtf8Name.size() < 255) {
73 longUtf8Name = longUtf8Name + "fф";
74 }
75 UNIT_ASSERT_EQUAL(longUtf8Name.size(), 255);
76 TFsPath longfile = dir1 / longUtf8Name;
77 Touch(longfile);
78
79 UNIT_ASSERT(NFs::Exists(longfile));
80 UNIT_ASSERT(NFs::Exists(file1));
81 UNIT_ASSERT(NFs::Exists(file2));
82 UNIT_ASSERT(NFs::Exists(file3));
83 // UNIT_ASSERT(NFs::Exists(link));
84
85 UNIT_ASSERT(!NFs::Remove(dir1));
86 NFs::RemoveRecursive(dir1);
87
88 UNIT_ASSERT(!NFs::Exists(file1));
89 UNIT_ASSERT(!NFs::Exists(file2));
90 UNIT_ASSERT(!NFs::Exists(file3));
91 // UNIT_ASSERT(!NFs::Exists(link));
92 UNIT_ASSERT(!NFs::Exists(subdir1));
93 UNIT_ASSERT(!NFs::Exists(longfile));
94 UNIT_ASSERT(!NFs::Exists(dir1));

Callers

nothing calls this directly

Calls 6

MakeDirectoryFunction · 0.85
TFileStatClass · 0.85
MakeDirectoryRecursiveFunction · 0.85
IsDirMethod · 0.80
TouchFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected