| 10 | |
| 11 | Y_UNIT_TEST_SUITE(TestFileStat) { |
| 12 | Y_UNIT_TEST(FileTest) { |
| 13 | TString fileName = "f1.txt"; |
| 14 | TFileStat oFs; |
| 15 | { |
| 16 | TFile file(fileName.data(), OpenAlways | WrOnly); |
| 17 | file.Write("1234567", 7); |
| 18 | |
| 19 | { |
| 20 | TFileStat fs(file); |
| 21 | UNIT_ASSERT(fs.IsFile()); |
| 22 | UNIT_ASSERT(!fs.IsDir()); |
| 23 | UNIT_ASSERT(!fs.IsSymlink()); |
| 24 | UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), (i64)fs.Size); |
| 25 | UNIT_ASSERT(fs.MTime >= fs.CTime); |
| 26 | UNIT_ASSERT(fs.NLinks == 1); |
| 27 | oFs = fs; |
| 28 | } |
| 29 | |
| 30 | UNIT_ASSERT(file.IsOpen()); |
| 31 | UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 7); |
| 32 | file.Close(); |
| 33 | } |
| 34 | TFileStat cFs(fileName); |
| 35 | UNIT_ASSERT(cFs.IsFile()); |
| 36 | UNIT_ASSERT(!cFs.IsDir()); |
| 37 | UNIT_ASSERT(!cFs.IsSymlink()); |
| 38 | UNIT_ASSERT_VALUES_EQUAL(cFs.Size, oFs.Size); |
| 39 | UNIT_ASSERT(cFs.MTime >= oFs.MTime); |
| 40 | UNIT_ASSERT_VALUES_EQUAL(cFs.CTime, oFs.CTime); |
| 41 | UNIT_ASSERT_VALUES_EQUAL(cFs.NLinks, oFs.NLinks); |
| 42 | UNIT_ASSERT_VALUES_EQUAL(cFs.Mode, oFs.Mode); |
| 43 | UNIT_ASSERT_VALUES_EQUAL(cFs.Uid, oFs.Uid); |
| 44 | UNIT_ASSERT_VALUES_EQUAL(cFs.Gid, oFs.Gid); |
| 45 | UNIT_ASSERT_VALUES_EQUAL(cFs.INode, oFs.INode); |
| 46 | UNIT_ASSERT(unlink(fileName.data()) == 0); |
| 47 | } |
| 48 | |
| 49 | Y_UNIT_TEST(DirTest) { |
| 50 | Mkdir("tmpd", MODE0777); |
nothing calls this directly
no test coverage detected