| 120 | UNIT_TEST_SUITE_REGISTRATION(TFileTest); |
| 121 | |
| 122 | void TFileTest::TestOpen() { |
| 123 | TString res; |
| 124 | TFile f1; |
| 125 | |
| 126 | try { |
| 127 | TFile f2("f1.txt", OpenExisting); |
| 128 | } catch (const yexception& e) { |
| 129 | res = e.what(); |
| 130 | } |
| 131 | UNIT_ASSERT(!res.empty()); |
| 132 | res.remove(); |
| 133 | |
| 134 | try { |
| 135 | TFile f2("f1.txt", OpenAlways); |
| 136 | f1 = f2; |
| 137 | } catch (const yexception& e) { |
| 138 | res = e.what(); |
| 139 | } |
| 140 | UNIT_ASSERT(res.empty()); |
| 141 | UNIT_ASSERT(f1.IsOpen()); |
| 142 | UNIT_ASSERT_VALUES_EQUAL(f1.GetName(), "f1.txt"); |
| 143 | UNIT_ASSERT_VALUES_EQUAL(f1.GetLength(), 0); |
| 144 | |
| 145 | try { |
| 146 | TFile f2("f1.txt", CreateNew); |
| 147 | } catch (const yexception& e) { |
| 148 | res = e.what(); |
| 149 | } |
| 150 | UNIT_ASSERT(!res.empty()); |
| 151 | res.remove(); |
| 152 | |
| 153 | f1.Close(); |
| 154 | UNIT_ASSERT(unlink("f1.txt") == 0); |
| 155 | } |
| 156 | |
| 157 | void TFileTest::TestOpenSync() { |
| 158 | TFile f1("f1.txt", CreateNew | Sync); |