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

Function Y_UNIT_TEST

util/system/mktemp_ut.cpp:16–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 static const unsigned int PathSegmentSizeLong = 255;
15
16 Y_UNIT_TEST(TestMakeTempName) {
17 const TFsPath systemTemp{GetSystemTempDir()};
18 UNIT_ASSERT(systemTemp.Exists());
19
20 for (auto dirNameLength : {PathSegmentSizeNormal, PathSegmentSizeLong}) {
21 const TFsPath testDir{systemTemp / TestDir};
22 testDir.MkDir();
23 UNIT_ASSERT(testDir.Exists());
24 Y_DEFER {
25 std::filesystem::remove_all(testDir.c_str());
26 };
27
28 const TString dirName(dirNameLength, 'X');
29 const TFsPath dirPath = testDir / dirName;
30 UNIT_ASSERT(std::filesystem::create_directory(dirPath.GetPath().c_str()));
31
32 TString tempFilePath;
33 try {
34 tempFilePath = MakeTempName(dirPath.c_str(), Prefix, Extension);
35 } catch (const TSystemError& ex) {
36 Cerr << "Unexpected exception: " << ex.what() << Endl;
37 }
38 UNIT_ASSERT(TFsPath{tempFilePath}.Exists());
39 }
40 }
41} // Y_UNIT_TEST_SUITE(MakeTempFileSuite)

Callers

nothing calls this directly

Calls 8

GetSystemTempDirFunction · 0.85
MakeTempNameFunction · 0.85
MkDirMethod · 0.80
remove_allClass · 0.50
create_directoryFunction · 0.50
ExistsMethod · 0.45
c_strMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected