| 596 | |
| 597 | template <typename DirIter> |
| 598 | static void checkContents(DirIter I, ArrayRef<StringRef> ExpectedOut) { |
| 599 | std::error_code EC; |
| 600 | SmallVector<StringRef, 4> Expected(ExpectedOut.begin(), ExpectedOut.end()); |
| 601 | SmallVector<std::string, 4> InputToCheck; |
| 602 | |
| 603 | // Do not rely on iteration order to check for contents, sort both |
| 604 | // content vectors before comparison. |
| 605 | for (DirIter E; !EC && I != E; I.increment(EC)) |
| 606 | InputToCheck.push_back(I->path()); |
| 607 | |
| 608 | llvm::sort(InputToCheck); |
| 609 | llvm::sort(Expected); |
| 610 | EXPECT_EQ(InputToCheck.size(), Expected.size()); |
| 611 | |
| 612 | unsigned LastElt = std::min(InputToCheck.size(), Expected.size()); |
| 613 | for (unsigned Idx = 0; Idx != LastElt; ++Idx) |
| 614 | EXPECT_EQ(StringRef(InputToCheck[Idx]), Expected[Idx]); |
| 615 | } |
| 616 | |
| 617 | TEST(VirtualFileSystemTest, OverlayIteration) { |
| 618 | IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem()); |