]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / search_n / iterator.cc
index fea009d2775244bb14a979030b3c938bcd7f4d6b..8fcf45ea85381d31603a35cb314b364ce3a04d9d 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 // terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
+// Free Software Foundation; either version 3, or (at your option)
 // any later version.
 
 // This library is distributed in the hope that it will be useful,
 // GNU General Public License for more details.
 
 // You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-DTEST_DEPTH=10" { target simulator } }
 
 // 25 algorithms, search_n
 
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
+#ifndef TEST_DEPTH
 #define TEST_DEPTH 14
+#endif
+
 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;
 }
 
@@ -52,12 +58,15 @@ lexstep(int* start, int length)
   return !carry;
 }
 
-using __gnu_test::test_container;
-using __gnu_test::random_access_iterator_wrapper;
-using __gnu_test::bidirectional_iterator_wrapper;
-using __gnu_test::forward_iterator_wrapper;
+int main() 
+{
+  using __gnu_test::test_container;
+  using __gnu_test::random_access_iterator_wrapper;
+  using __gnu_test::bidirectional_iterator_wrapper;
+  using __gnu_test::forward_iterator_wrapper;
+  
+  using std::search_n;
 
-int main() {
   test_container<int,forward_iterator_wrapper> con(array1,array1 + 10);
   VERIFY(search_n(con.end(), con.end(), 0, 1) == con.end());
   VERIFY(search_n(con.end(), con.end(), 1, 1) == con.end());
@@ -83,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));
          }