1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/unittests/ADT/DepthFirstIteratorTest.cpp
Chandler Carruth 87b8e94f84 Re-sort #include lines for unittests. This uses a slightly modified
clang-format (https://reviews.llvm.org/D33932) to keep primary headers
at the top and handle new utility headers like 'gmock' consistently with
other utility headers.

No other change was made. I did no manual edits, all of this is
clang-format.

This should allow other changes to have more clear and focused diffs,
and is especially motivated by moving some headers into more focused
libraries.

llvm-svn: 304786
2017-06-06 11:06:56 +00:00

55 lines
1.3 KiB
C++

//=== llvm/unittest/ADT/DepthFirstIteratorTest.cpp - DFS iterator tests ---===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/DepthFirstIterator.h"
#include "TestGraph.h"
#include "gtest/gtest.h"
using namespace llvm;
namespace llvm {
template <typename T> struct CountedSet {
typedef typename SmallPtrSet<T, 4>::iterator iterator;
SmallPtrSet<T, 4> S;
int InsertVisited = 0;
std::pair<iterator, bool> insert(const T &Item) {
InsertVisited++;
return S.insert(Item);
}
size_t count(const T &Item) const { return S.count(Item); }
void completed(T) { }
};
template <typename T> class df_iterator_storage<CountedSet<T>, true> {
public:
df_iterator_storage(CountedSet<T> &VSet) : Visited(VSet) {}
CountedSet<T> &Visited;
};
TEST(DepthFirstIteratorTest, ActuallyUpdateIterator) {
typedef CountedSet<Graph<3>::NodeType *> StorageT;
typedef df_iterator<Graph<3>, StorageT, true> DFIter;
Graph<3> G;
G.AddEdge(0, 1);
G.AddEdge(0, 2);
StorageT S;
for (auto N : make_range(DFIter::begin(G, S), DFIter::end(G, S)))
(void)N;
EXPECT_EQ(3, S.InsertVisited);
}
}