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

Method TestOpen

util/system/file_ut.cpp:122–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120UNIT_TEST_SUITE_REGISTRATION(TFileTest);
121
122void 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
157void TFileTest::TestOpenSync() {
158 TFile f1("f1.txt", CreateNew | Sync);

Callers

nothing calls this directly

Calls 7

whatMethod · 0.45
emptyMethod · 0.45
removeMethod · 0.45
IsOpenMethod · 0.45
GetNameMethod · 0.45
GetLengthMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected