]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc
All files: Update FSF address.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / mismatch / 1.cc
CommitLineData
0e994557
PC
1// Copyright (C) 2005 Free Software Foundation, Inc.
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 2, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING. If not, write to the Free
83f51799 16// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
0e994557
PC
17// USA.
18
19// 25.1.7 [lib.mismatch]
20
21#include <algorithm>
22#include <testsuite_hooks.h>
23#include <testsuite_iterators.h>
24
25using __gnu_test::test_container;
26using __gnu_test::input_iterator_wrapper;
27
28typedef test_container<int, input_iterator_wrapper> Container;
29int array1[] = {0, 1};
30int array2[] = {1, 0};
31int array3[] = {1, 0, 1};
32
33void test1a()
34{
35 Container con1(array1, array1);
36 Container con2(array2, array2);
37 VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr
38 == array1 );
39}
40
41void test1b()
42{
43 Container con1(array1, array1);
44 Container con2(array2, array2);
45 VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr
46 == array2 );
47}
48
49void test2a()
50{
51 Container con1(array1, array1 + 2);
52 Container con2(array2, array2 + 2);
53 VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr
54 == array1 );
55}
56
57void test2b()
58{
59 Container con1(array1, array1 + 2);
60 Container con2(array2, array2 + 2);
61 VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr
62 == array2 );
63}
64
65void test3a()
66{
67 Container con3(array3, array3 + 2);
68 Container con2(array2, array2 + 2);
69 VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).first.ptr
70 == array3 + 2 );
71}
72
73void test3b()
74{
75 Container con3(array3, array3 + 2);
76 Container con2(array2, array2 + 2);
77 VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).second.ptr
78 == array2 + 2 );
79}
80
81int main()
82{
83 test1a();
84 test1b();
85 test2a();
86 test2b();
87 test3a();
88 test3b();
89}