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

Method TestSort

util/folder/iterator_ut.cpp:176–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174 }
175
176 inline void TestSort() {
177 TDirHier dh;
178 const TString dir("tmpdir");
179
180 // prepare fs
181 {
182 TMersenne<ui32> rnd;
183 const TString prefixes[] = {
184 "a", "b", "xxx", "111", ""};
185
186 dh.AddDir(dir);
187
188 for (size_t i = 0; i < 100; ++i) {
189 const TString fname = dir + LOCSLASH_C + prefixes[i % Y_ARRAY_SIZE(prefixes)] + ToString(rnd.GenRand());
190
191 dh.AddFile(fname);
192 }
193 }
194
195 TVector<TString> fnames;
196
197 {
198 TDirIterator d(dir, TDirIterator::TOptions().SetSortByName());
199
200 for (auto it = d.begin(); it != d.end(); ++it) {
201 if (it->fts_info == FTS_F) {
202 fnames.push_back(it->fts_name);
203 }
204 }
205 }
206
207 TVector<TString> sorted(fnames);
208 Sort(sorted.begin(), sorted.end());
209
210 UNIT_ASSERT_VALUES_EQUAL(JoinWithNewline(fnames), JoinWithNewline(sorted));
211 }
212
213 inline void TestError() {
214 UNIT_ASSERT_EXCEPTION(TDirIterator("./notexistingfilename"), TDirIterator::TError);

Callers

nothing calls this directly

Calls 10

JoinWithNewlineFunction · 0.85
AddDirMethod · 0.80
TOptionsClass · 0.70
ToStringFunction · 0.50
SortFunction · 0.50
GenRandMethod · 0.45
AddFileMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected