| 54 | }; |
| 55 | |
| 56 | void TFtsTest::TestSimple() { |
| 57 | const char* dotPath[2] = {"." LOCSLASH_S, nullptr}; |
| 58 | TFileTree currentDirTree((char* const*)dotPath, 0, FtsCmp); |
| 59 | UNIT_ASSERT(currentDirTree()); |
| 60 | TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path); |
| 61 | MakeDirIfNotExist(tempDir().data()); |
| 62 | MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir1").data()); |
| 63 | MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data()); |
| 64 | MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file2").data()); |
| 65 | MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir2").data()); |
| 66 | MakeFile((tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file3").data()); |
| 67 | MakeFile((tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data()); |
| 68 | |
| 69 | const char* path[2] = {tempDir().data(), nullptr}; |
| 70 | TFileTree fileTree((char* const*)path, 0, FtsCmp); |
| 71 | UNIT_ASSERT(fileTree()); |
| 72 | CheckEnt(yfts_read(fileTree()), tempDir().data(), FTS_D); |
| 73 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1").data(), FTS_D); |
| 74 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data(), FTS_F); |
| 75 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file2").data(), FTS_F); |
| 76 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1").data(), FTS_DP); |
| 77 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_D); |
| 78 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file3").data(), FTS_F); |
| 79 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data(), FTS_F); |
| 80 | CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_DP); |
| 81 | CheckEnt(yfts_read(fileTree()), (tempDir()).data(), FTS_DP); |
| 82 | UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr); |
| 83 | } |
| 84 | |
| 85 | class TTempDirWithLostAccess: public TTempDir { |
| 86 | public: |
nothing calls this directly
no test coverage detected