| 94 | } |
| 95 | |
| 96 | inline void TestResize() { |
| 97 | TTempFile tmp("tmp"); |
| 98 | |
| 99 | { |
| 100 | TFile file(tmp.Name(), OpenAlways | WrOnly); |
| 101 | |
| 102 | file.Write("1234567", 7); |
| 103 | file.Seek(3, sSet); |
| 104 | |
| 105 | file.Resize(5); |
| 106 | UNIT_ASSERT_EQUAL(file.GetLength(), 5); |
| 107 | UNIT_ASSERT_EQUAL(file.GetPosition(), 3); |
| 108 | |
| 109 | file.Resize(12); |
| 110 | UNIT_ASSERT_EQUAL(file.GetLength(), 12); |
| 111 | UNIT_ASSERT_EQUAL(file.GetPosition(), 3); |
| 112 | } |
| 113 | |
| 114 | const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll(); |
| 115 | UNIT_ASSERT_EQUAL(data.length(), 12); |
| 116 | UNIT_ASSERT(data.StartsWith("12345")); |
| 117 | } |
| 118 | }; |
| 119 | |
| 120 | UNIT_TEST_SUITE_REGISTRATION(TFileTest); |
nothing calls this directly
no test coverage detected