| 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) |
nothing calls this directly
no test coverage detected