|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // STLport regression testsuite component. |
|
19 // To compile as a separate example, please #define MAIN. |
|
20 |
|
21 #include <vector> |
|
22 #include <algorithm> |
|
23 #include <numeric> |
|
24 #include <iostream> |
|
25 |
|
26 #ifdef MAIN |
|
27 #define mismtch1_test main |
|
28 #endif |
|
29 |
|
30 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
31 using namespace std; |
|
32 #endif |
|
33 int mismtch1_test(int, char**) |
|
34 { |
|
35 cout<<"Results of mismtch1_test:"<<endl; |
|
36 typedef vector<int> IntVec; |
|
37 int failures = 0; |
|
38 IntVec v1(10); |
|
39 IntVec v2(v1.size()); |
|
40 iota(v1.begin(), v1.end(), 0); |
|
41 iota(v2.begin(), v2.end(), 0); |
|
42 pair <IntVec::iterator, IntVec::iterator> result = |
|
43 mismatch(v1.begin(), v1.end(), v2.begin()); |
|
44 if(result.first == v1.end() && result.second == v2.end()) |
|
45 cout << "v1 and v2 are the same" << endl; |
|
46 else |
|
47 { |
|
48 failures++; |
|
49 cout << "mismatch at index: " <<(result.first - v1.begin()) << endl; |
|
50 } |
|
51 v2[v2.size()/2] = 42; |
|
52 result = mismatch(v1.begin(), v1.end(), v2.begin()); |
|
53 if(result.first == v1.end() && result.second == v2.end()) |
|
54 { |
|
55 failures++; |
|
56 cout << "v1 and v2 are the same" << endl; |
|
57 } |
|
58 else |
|
59 cout << "mismatch at index: " <<(result.first - v1.begin()) << endl; |
|
60 return failures; |
|
61 } |