summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/testsuite/25_algorithms
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-08 16:12:13 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-08 16:12:13 +0000
commit5b67eee55e2efd02eea37d1dd2647b908dfc8649 (patch)
tree2f38fba2ba34dabdab8dacae50f6a8e640cce001 /libstdc++-v3/testsuite/25_algorithms
parentb82f961e82aeaeef49a8f9e6d94cb2c5800fa2a1 (diff)
downloadppe42-gcc-5b67eee55e2efd02eea37d1dd2647b908dfc8649.tar.gz
ppe42-gcc-5b67eee55e2efd02eea37d1dd2647b908dfc8649.zip
* include/bits/stl_algo.h (is_permutation): Add overloads from N3671.
* include/bits/stl_algobase.h (equal, mismatch): Likewise. * testsuite/25_algorithms/equal/1.cc: Remove duplicate test case. * testsuite/25_algorithms/equal/2.cc: New. * testsuite/25_algorithms/equal/check_type2.cc: New. * testsuite/25_algorithms/is_permutationqual/2.cc: New. * testsuite/25_algorithms/is_permutationqual/check_type2.cc: New. * testsuite/25_algorithms/mismatch/2.cc: New. * testsuite/25_algorithms/mismatch/check_type2.cc: New. * testsuite/util/testsuite_iterators.h: Fix spelling. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199854 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms')
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/equal/1.cc12
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/equal/2.cc193
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/equal/check_type2.cc48
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/is_permutation/2.cc115
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type2.cc46
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc2
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/mismatch/2.cc175
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/mismatch/check_type2.cc51
8 files changed, 633 insertions, 9 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc
index 22af7650f0e..f8c13550de3 100644
--- a/libstdc++-v3/testsuite/25_algorithms/equal/1.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc
@@ -27,6 +27,8 @@ int array1[] = {0, 1};
int array2[] = {1, 0};
int array3[] = {1, 0};
+bool __attribute__((unused)) test = false;
+
void test1()
{
Container con1(array1, array1);
@@ -45,17 +47,10 @@ void test3()
{
Container con1(array1, array1 + 2);
Container con2(array2, array2 + 2);
- VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) );
-}
-
-void test4()
-{
- Container con1(array1, array1 + 2);
- Container con2(array2, array2 + 2);
VERIFY( !std::equal(con1.begin(), con1.end(), con2.begin()) );
}
-void test5()
+void test4()
{
Container con3(array3, array3 + 2);
Container con2(array2, array2 + 2);
@@ -68,5 +63,4 @@ int main()
test2();
test3();
test4();
- test5();
}
diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/2.cc b/libstdc++-v3/testsuite/25_algorithms/equal/2.cc
new file mode 100644
index 00000000000..012609f7fe8
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/equal/2.cc
@@ -0,0 +1,193 @@
+// Copyright (C) 2013 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 25.2.11 [alg.equal]
+
+// { dg-options "-std=gnu++1y" }
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+using __gnu_test::random_access_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Container;
+typedef test_container<int, random_access_iterator_wrapper> RA_Container;
+int array1[] = {0, 1};
+int array2[] = {1, 0};
+int array3[] = {1, 0};
+
+struct equal_to
+{
+ static int count;
+
+ bool operator()(int l, int r)
+ {
+ ++count;
+ return l == r;
+ }
+} eq;
+
+int equal_to::count = 0;
+
+bool __attribute__((unused)) test = false;
+
+void test1()
+{
+ const Container con1(array1, array1);
+ const Container con2(array2, array2);
+
+ auto c1 = con1;
+ auto c2 = con2;
+ VERIFY( std::equal(c1.begin(), c1.end(), c2.begin(), c2.end()) );
+ VERIFY( equal_to::count == 0 );
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( std::equal(c1.begin(), c1.end(), c2.begin(), c2.end(), eq) );
+ VERIFY( equal_to::count == 0 );
+}
+
+void test2()
+{
+ const Container con1(array1, array1 + 0);
+ const Container con2(array2, array2 + 2);
+
+ auto c1 = con1;
+ auto c2 = con2;
+ VERIFY( !std::equal(c1.begin(), c1.end(), c2.begin(), c2.end()) );
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( !std::equal(c1.begin(), c1.end(), c2.begin(), c2.end(), eq) );
+ VERIFY( equal_to::count == 0 );
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( !std::equal(c2.begin(), c2.end(), c1.begin(), c1.end()) );
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( !std::equal(c2.begin(), c2.end(), c1.begin(), c1.end(), eq) );
+ VERIFY( equal_to::count == 0 );
+}
+
+void test3()
+{
+ const Container con1(array1, array1 + 2);
+ const Container con2(array2, array2 + 2);
+
+ auto c1 = con1;
+ auto c2 = con2;
+ VERIFY( !std::equal(c1.begin(), c1.end(), c2.begin(), c2.end()) );
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( !std::equal(c1.begin(), c1.end(), c2.begin(), c2.end(), eq) );
+ VERIFY( equal_to::count == 1 );
+ equal_to::count = 0;
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( !std::equal(c2.begin(), c2.end(), c1.begin(), c1.end()) );
+
+ c1 = con1;
+ c2 = con2;
+ VERIFY( !std::equal(c2.begin(), c2.end(), c1.begin(), c1.end(), eq) );
+ VERIFY( equal_to::count == 1 );
+ equal_to::count = 0;
+}
+
+void test4()
+{
+ const Container con3(array3, array3 + 2);
+ const Container con2(array2, array2 + 2);
+
+ auto c3 = con3;
+ auto c2 = con2;
+ VERIFY( std::equal(c3.begin(), c3.end(), c2.begin(), c2.end()) );
+
+ c3 = con3;
+ c2 = con2;
+ VERIFY( std::equal(c3.begin(), c3.end(), c2.begin(), c2.end(), eq) );
+ VERIFY( equal_to::count == 2 );
+ equal_to::count = 0;
+
+ c3 = con3;
+ c2 = con2;
+ VERIFY( std::equal(c2.begin(), c2.end(), c3.begin(), c3.end()) );
+
+ c3 = con3;
+ c2 = con2;
+ VERIFY( std::equal(c2.begin(), c2.end(), c3.begin(), c3.end(), eq) );
+ VERIFY( equal_to::count == 2 );
+ equal_to::count = 0;
+}
+
+void test5()
+{
+ const Container con3(array3, array3 + 1);
+ const Container con2(array2, array2 + 2);
+
+ auto c3 = con3;
+ auto c2 = con2;
+ VERIFY( !std::equal(c3.begin(), c3.end(), c2.begin(), c2.end()) );
+
+ c3 = con3;
+ c2 = con2;
+ VERIFY( !std::equal(c3.begin(), c3.end(), c2.begin(), c2.end(), eq) );
+ VERIFY( equal_to::count == 1 );
+ equal_to::count = 0;
+
+ c3 = con3;
+ c2 = con2;
+ VERIFY( !std::equal(c2.begin(), c2.end(), c3.begin(), c3.end()) );
+
+ c3 = con3;
+ c2 = con2;
+ VERIFY( !std::equal(c2.begin(), c2.end(), c3.begin(), c3.end(), eq) );
+ VERIFY( equal_to::count == 1 );
+ equal_to::count = 0;
+}
+
+void test6()
+{
+ RA_Container c3(array3, array3 + 1);
+ RA_Container c2(array2, array2 + 2);
+
+ VERIFY( !std::equal(c3.begin(), c3.end(), c2.begin(), c2.end()) );
+
+ VERIFY( !std::equal(c3.begin(), c3.end(), c2.begin(), c2.end(), eq) );
+ VERIFY( equal_to::count == 0 );
+
+ VERIFY( !std::equal(c2.begin(), c2.end(), c3.begin(), c3.end()) );
+
+ VERIFY( !std::equal(c2.begin(), c2.end(), c3.begin(), c3.end(), eq) );
+ VERIFY( equal_to::count == 0 );
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/check_type2.cc b/libstdc++-v3/testsuite/25_algorithms/equal/check_type2.cc
new file mode 100644
index 00000000000..c80cced5923
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/equal/check_type2.cc
@@ -0,0 +1,48 @@
+// Copyright (C) 2013 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 25.2.11 [alg.equal]
+
+// { dg-do compile }
+// { dg-options " -std=gnu++1y " }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+using __gnu_test::input_iterator_wrapper;
+
+struct Lhs1 { };
+
+struct Rhs1 { };
+
+bool operator==(const Lhs1&, const Rhs1&) {return true;}
+
+struct Lhs2 { };
+
+struct Rhs2 { };
+
+bool
+predicate(const Lhs2&, const Rhs2&) {return true;}
+
+bool
+test1(input_iterator_wrapper<Lhs1>& lhs1,
+ input_iterator_wrapper<Rhs1>& rhs1)
+{ return std::equal(lhs1, lhs1, rhs1, rhs1); }
+
+bool
+test2(input_iterator_wrapper<Lhs2>& lhs2,
+ input_iterator_wrapper<Rhs2>& rhs2)
+{ return std::equal(lhs2, lhs2, rhs2, rhs2, predicate); }
diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/2.cc
new file mode 100644
index 00000000000..d573fa2c932
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/2.cc
@@ -0,0 +1,115 @@
+// { dg-options "-std=gnu++1y" }
+
+// Copyright (C) 2013 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 25.2.12 [alg.is_permutation] Is permutation
+
+#include <algorithm>
+#include <functional>
+#include <testsuite_hooks.h>
+
+struct my_equal_to
+{
+ bool
+ operator()(int __x, int __y) const
+ { return __x % 10 == __y % 10; }
+};
+
+const int arr0[] = { 11, 22, 33, 44, 55 };
+
+void
+do_test(int arr1[5], bool np = true, unsigned N = 5)
+{
+ bool test __attribute__((unused)) = true;
+
+ do
+ VERIFY( std::is_permutation(arr1, arr1 + 5, arr0, arr0 + N) == np );
+ while (std::next_permutation(arr1, arr1 + 5));
+}
+
+template<typename Predicate>
+ void
+ do_test(int arr1[5], Predicate pred, bool np = true, unsigned N = 5)
+ {
+ bool test __attribute__((unused)) = true;
+
+ do
+ VERIFY( std::is_permutation(arr1, arr1 + 5, arr0, arr0 + N, pred) == np );
+ while (std::next_permutation(arr1, arr1 + 5));
+ }
+
+void test01()
+{
+ int arr1[] = { 11, 22, 33, 44, 55 };
+ do_test(arr1);
+ do_test(arr1, false, 4);
+
+ int arr2[] = { 11, 33, 33, 44, 55 };
+ do_test(arr2, false);
+
+ int arr3[] = { 33, 33, 33, 44, 44 };
+ do_test(arr3, false);
+
+ int arr4[] = { 11, 22, 33, 44, 55 };
+ do_test(arr4, std::equal_to<int>());
+ do_test(arr4, std::equal_to<int>(), false, 4);
+
+ int arr5[] = { 11, 33, 33, 44, 55 };
+ do_test(arr5, std::equal_to<int>(), false);
+
+ int arr6[] = { 33, 33, 33, 44, 44 };
+ do_test(arr6, std::equal_to<int>(), false);
+
+ int arr7[] = { 1, 2, 3, 4, 5 };
+ do_test(arr7, my_equal_to());
+ do_test(arr7, my_equal_to(), false, 4);
+
+ int arr8[] = { 1, 3, 3, 4, 5 };
+ do_test(arr8, my_equal_to(), false);
+
+ int arr9[] = { 3, 3, 3, 4, 4 };
+ do_test(arr9, my_equal_to(), false);
+
+ int arr10[] = { 111, 222, 333, 444, 555 };
+ do_test(arr10, my_equal_to());
+ do_test(arr10, my_equal_to(), false, 4);
+
+ int arr11[] = { 1, 222, 33, 4, 55 };
+ do_test(arr11, my_equal_to());
+
+ int arr12[] = { 111, 333, 333, 444, 555 };
+ do_test(arr12, my_equal_to(), false);
+
+ int arr13[] = { 333, 333, 333, 444, 444 };
+ do_test(arr13, my_equal_to(), false);
+}
+
+bool thrower(int, int) { throw 1; }
+
+void test02()
+{
+ int arr[] = { 11, 22, 33 };
+ using namespace std;
+ is_permutation(begin(arr0), end(arr0), begin(arr), end(arr), thrower);
+}
+
+int main()
+{
+ test01();
+ test02();
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type2.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type2.cc
new file mode 100644
index 00000000000..9cdf87daf08
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type2.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2013 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 25.2.12 [alg.is_permutation] Is permutation
+
+// { dg-do compile }
+// { dg-options " -std=gnu++1y " }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::forward_iterator_wrapper;
+
+struct X { };
+bool operator==(const X&, const X) { return true; }
+
+struct Y { };
+bool predicate(const Y&, const Y&) { return true; }
+
+bool
+test1(forward_iterator_wrapper<X>& x1,
+ forward_iterator_wrapper<X>& x2)
+{
+ return std::is_permutation(x1, x1, x2, x2);
+}
+
+bool
+test2(forward_iterator_wrapper<Y>& y1,
+ forward_iterator_wrapper<Y>& y2)
+{
+ return std::is_permutation(y1, y1, y2, y2, predicate);
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc
index bcf2f5e12f2..c70d778a142 100644
--- a/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc
@@ -29,6 +29,8 @@ int array1[] = {0, 1};
int array2[] = {1, 0};
int array3[] = {1, 0, 1};
+bool __attribute__((unused)) test = false;
+
void test1a()
{
Container con1(array1, array1);
diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/2.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/2.cc
new file mode 100644
index 00000000000..4eac4a9e3ef
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/2.cc
@@ -0,0 +1,175 @@
+// Copyright (C) 2013 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 25.2.10 [mismatch]
+
+// { dg-options " -std=gnu++1y " }
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Container;
+
+int array1[] = {0, 1};
+int array2[] = {1, 0};
+int array3[] = {1, 0, 1};
+
+struct equal_to
+{
+ static int count;
+
+ bool operator()(int l, int r)
+ {
+ ++count;
+ return l == r;
+ }
+} eq;
+
+int equal_to::count = 0;
+
+bool __attribute__((unused)) test = false;
+
+void test1()
+{
+ // empty ranges
+ Container con1(array1, array1);
+ Container con2(array2, array2);
+ auto res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end());
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+ res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end(), eq);
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+ VERIFY( equal_to::count == 0 );
+}
+
+void test2()
+{
+ // first range empty, second non-empty
+ Container con1(array1, array1);
+ Container con2(array2, array2 + 2);
+ auto res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end());
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+
+ res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end(), eq);
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+ VERIFY( equal_to::count == 0 );
+}
+
+void test3()
+{
+ // first range non-empty, second empty
+ Container con1(array1, array1 + 2);
+ Container con2(array2, array2);
+ auto res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end());
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+
+ res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end(), eq);
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+ VERIFY( equal_to::count == 0 );
+}
+
+void test4()
+{
+ // non-empty, mismatching ranges
+ Container con1(array1, array1 + 2);
+ Container con2(array2, array2 + 2);
+ auto res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end());
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+
+ con1.bounds.first = array1;
+ con2.bounds.first = array2;
+ res = std::mismatch(con1.begin(), con1.end(), con2.begin(), con2.end(), eq);
+ VERIFY( res.first.ptr == array1 );
+ VERIFY( res.second.ptr == array2 );
+ VERIFY( equal_to::count == 1 );
+ equal_to::count = 0;
+}
+
+void test5()
+{
+ // non-empty, matching ranges
+ Container con3(array3, array3 + 2);
+ Container con2(array2, array2 + 2);
+ auto res = std::mismatch(con3.begin(), con3.end(), con2.begin(), con2.end());
+ VERIFY( res.first.ptr == array3 + 2 );
+ VERIFY( res.second.ptr == array2 + 2 );
+
+ con3.bounds.first = array3;
+ con2.bounds.first = array2;
+ res = std::mismatch(con3.begin(), con3.end(), con2.begin(), con2.end(), eq);
+ VERIFY( res.first.ptr == array3 + 2 );
+ VERIFY( res.second.ptr == array2 + 2 );
+ VERIFY( equal_to::count == 2 );
+ equal_to::count = 0;
+}
+
+void test6()
+{
+ // non-empty, matching sub-ranges, first range longer
+ Container con3(array3, array3 + 3);
+ Container con2(array2, array2 + 2);
+ auto res = std::mismatch(con3.begin(), con3.end(), con2.begin(), con2.end());
+ VERIFY( res.first.ptr == array3 + 2 );
+ VERIFY( res.second.ptr == array2 + 2 );
+
+ con3.bounds.first = array3;
+ con2.bounds.first = array2;
+ res = std::mismatch(con3.begin(), con3.end(), con2.begin(), con2.end(), eq);
+ VERIFY( res.first.ptr == array3 + 2 );
+ VERIFY( res.second.ptr == array2 + 2 );
+ VERIFY( equal_to::count == 2 );
+ equal_to::count = 0;
+}
+
+void test7()
+{
+ // non-empty, matching sub-ranges, second range longer
+ Container con3(array3, array3 + 3);
+ Container con2(array2, array2 + 2);
+ auto res = std::mismatch(con2.begin(), con2.end(), con3.begin(), con3.end());
+ VERIFY( res.first.ptr == array2 + 2 );
+ VERIFY( res.second.ptr == array3 + 2 );
+
+ con3.bounds.first = array3;
+ con2.bounds.first = array2;
+ res = std::mismatch(con2.begin(), con2.end(), con3.begin(), con3.end(), eq);
+ VERIFY( res.first.ptr == array2 + 2 );
+ VERIFY( res.second.ptr == array3 + 2 );
+ VERIFY( equal_to::count == 2 );
+ equal_to::count = 0;
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type2.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type2.cc
new file mode 100644
index 00000000000..3ec1f88401a
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type2.cc
@@ -0,0 +1,51 @@
+// Copyright (C) 2005-2013 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 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 25.2.10 [mismatch]
+
+// { dg-options " -std=gnu++1y " }
+// { dg-do compile }
+
+#include <algorithm>
+#include <utility>
+#include <testsuite_iterators.h>
+
+using __gnu_test::input_iterator_wrapper;
+
+struct Lhs1 { };
+
+struct Rhs1 { };
+
+bool operator==(const Lhs1&, const Rhs1&) {return true;}
+
+struct Lhs2 { };
+
+struct Rhs2 { };
+
+bool predicate(const Lhs2&, const Rhs2&) {return true;}
+
+std::pair<input_iterator_wrapper<Lhs1>, input_iterator_wrapper<Rhs1> >
+test1(input_iterator_wrapper<Lhs1>& lhs1, input_iterator_wrapper<Rhs1>& rhs1)
+{
+ return std::mismatch(lhs1, lhs1, rhs1, rhs1);
+}
+
+std::pair<input_iterator_wrapper<Lhs2>, input_iterator_wrapper<Rhs2> >
+test2(input_iterator_wrapper<Lhs2>& lhs2, input_iterator_wrapper<Rhs2>& rhs2)
+{
+ return std::mismatch(lhs2, lhs2, rhs2, rhs2, predicate);
+}
OpenPOWER on IntegriCloud