1 //=== llvm/unittest/ADT/DepthFirstIteratorTest.cpp - DFS iterator tests ---===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/DepthFirstIterator.h"
11 #include "TestGraph.h"
12 #include "gtest/gtest.h"
18 template <typename T
> struct CountedSet
{
19 typedef typename SmallPtrSet
<T
, 4>::iterator iterator
;
22 int InsertVisited
= 0;
24 std::pair
<iterator
, bool> insert(const T
&Item
) {
26 return S
.insert(Item
);
29 size_t count(const T
&Item
) const { return S
.count(Item
); }
34 template <typename T
> class df_iterator_storage
<CountedSet
<T
>, true> {
36 df_iterator_storage(CountedSet
<T
> &VSet
) : Visited(VSet
) {}
38 CountedSet
<T
> &Visited
;
41 TEST(DepthFirstIteratorTest
, ActuallyUpdateIterator
) {
42 typedef CountedSet
<Graph
<3>::NodeType
*> StorageT
;
43 typedef df_iterator
<Graph
<3>, StorageT
, true> DFIter
;
49 for (auto N
: make_range(DFIter::begin(G
, S
), DFIter::end(G
, S
)))
52 EXPECT_EQ(3, S
.InsertVisited
);