| 31 | } |
| 32 | |
| 33 | void TFileListTest::TestPrefix() { |
| 34 | TTempDir tempDir("nonexistingdir"); |
| 35 | TFile((tempDir() + LOCSLASH_S "good_file1").data(), CreateAlways); |
| 36 | TFile((tempDir() + LOCSLASH_S "good_file2").data(), CreateAlways); |
| 37 | TFile((tempDir() + LOCSLASH_S "bad_file1").data(), CreateAlways); |
| 38 | TFile((tempDir() + LOCSLASH_S "bad_file2").data(), CreateAlways); |
| 39 | |
| 40 | const bool SORT = true; |
| 41 | TFileList fileList; |
| 42 | { |
| 43 | fileList.Fill(tempDir().data(), "good_file", SORT); |
| 44 | UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file1"); |
| 45 | UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file2"); |
| 46 | UNIT_ASSERT_EQUAL(fileList.Next(), nullptr); |
| 47 | } |
| 48 | { |
| 49 | fileList.Fill(tempDir().data(), "bad_file", SORT); |
| 50 | UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file1"); |
| 51 | UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file2"); |
| 52 | UNIT_ASSERT_EQUAL(fileList.Next(), nullptr); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | UNIT_TEST_SUITE_REGISTRATION(TFileListTest); |