]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc
re PR libstdc++/58358 (search_n has a Complexity violation for random access iterator)
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / search_n / iterator.cc
index 27cffe741167bf7aae20fabd49908f98d0c27a06..10616960dc239f9fa6e7e6851c5d6302935b3d9c 100644 (file)
 int array1[11] = {0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0};
 int array2[TEST_DEPTH];
 
+int pred_count;
 bool 
 pred(int i, int j)
 {
+  ++pred_count;
   return i == j;
 }
 
@@ -90,16 +92,22 @@ int main()
 
            int* t1 = search_n(forwardcon.begin(),
                               forwardcon.end(), j, 1).ptr;
+           pred_count = 0;
            int* t2 = search_n(forwardcon.begin(),
                               forwardcon.end(), j, 1, pred).ptr;
+           VERIFY(pred_count <= i);
            int* t3 = search_n(bidircon.begin(),
                               bidircon.end(), j, 1).ptr;
+           pred_count = 0;
            int* t4 = search_n(bidircon.begin(),
                               bidircon.end(), j, 1, pred).ptr;
+           VERIFY(pred_count <= i);
            int* t5 = search_n(randomcon.begin(),
                               randomcon.end(), j, 1).ptr;
+           pred_count = 0;
            int* t6 = search_n(randomcon.begin(),
                               randomcon.end(), j, 1, pred).ptr;
+           VERIFY(pred_count <= i);
            VERIFY((t1 == t2) && (t2 == t3) && (t3 == t4) &&
                   (t4 == t5) && (t5 == t6));
          }