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

Method TestEnsureExists

util/system/fs_ut.cpp:298–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298void TFsTest::TestEnsureExists() {
299 TFsPath fileExists = "tmp_file_абвг.txt";
300 TFsPath nonExists = "tmp2_file_абвг.txt";
301 {
302 NFs::Remove(fileExists);
303 NFs::Remove(nonExists);
304 TFile file(fileExists, CreateNew | WrOnly);
305 file.Write("1234567", 7);
306 }
307
308 UNIT_ASSERT_NO_EXCEPTION(NFs::EnsureExists(fileExists));
309 UNIT_ASSERT_EXCEPTION(NFs::EnsureExists(nonExists), TFileError);
310
311 TStringBuilder expected;
312 TString got;
313 try {
314 NFs::EnsureExists(nonExists);
315 expected << __LOCATION__;
316 } catch (const TFileError& err) {
317 got = err.what();
318 }
319 UNIT_ASSERT(got.Contains(expected));
320 UNIT_ASSERT(got.Contains(NFs::CurrentWorkingDirectory()));
321
322 UNIT_ASSERT(NFs::Remove(fileExists));
323}

Callers

nothing calls this directly

Calls 3

WriteMethod · 0.45
whatMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected