31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <vector>
|
|
6 |
#include <algorithm>
|
|
7 |
#include <numeric>
|
|
8 |
#include <iostream>
|
|
9 |
|
|
10 |
#ifdef MAIN
|
|
11 |
#define mismtch1_test main
|
|
12 |
#endif
|
|
13 |
|
|
14 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
15 |
using namespace std;
|
|
16 |
#endif
|
|
17 |
int mismtch1_test(int, char**)
|
|
18 |
{
|
|
19 |
cout<<"Results of mismtch1_test:"<<endl;
|
|
20 |
typedef vector<int> IntVec;
|
|
21 |
int failures = 0;
|
|
22 |
IntVec v1(10);
|
|
23 |
IntVec v2(v1.size());
|
|
24 |
iota(v1.begin(), v1.end(), 0);
|
|
25 |
iota(v2.begin(), v2.end(), 0);
|
|
26 |
pair <IntVec::iterator, IntVec::iterator> result =
|
|
27 |
mismatch(v1.begin(), v1.end(), v2.begin());
|
|
28 |
if(result.first == v1.end() && result.second == v2.end())
|
|
29 |
cout << "v1 and v2 are the same" << endl;
|
|
30 |
else
|
|
31 |
{
|
|
32 |
failures++;
|
|
33 |
cout << "mismatch at index: " <<(result.first - v1.begin()) << endl;
|
|
34 |
}
|
|
35 |
v2[v2.size()/2] = 42;
|
|
36 |
result = mismatch(v1.begin(), v1.end(), v2.begin());
|
|
37 |
if(result.first == v1.end() && result.second == v2.end())
|
|
38 |
{
|
|
39 |
failures++;
|
|
40 |
cout << "v1 and v2 are the same" << endl;
|
|
41 |
}
|
|
42 |
else
|
|
43 |
cout << "mismatch at index: " <<(result.first - v1.begin()) << endl;
|
|
44 |
return failures;
|
|
45 |
}
|