31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <algorithm>
|
|
6 |
#include <iostream>
|
|
7 |
#include <cstring>
|
|
8 |
|
|
9 |
#ifdef MAIN
|
|
10 |
#define mismtch2_test main
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
14 |
using namespace std;
|
|
15 |
#endif
|
|
16 |
|
|
17 |
bool str_equal(const char* a_, const char* b_)
|
|
18 |
{
|
|
19 |
return strcmp(a_, b_) == 0 ? 1 : 0;
|
|
20 |
}
|
|
21 |
|
|
22 |
int mismtch2_test(int, char**)
|
|
23 |
{
|
|
24 |
cout<<"Results of mismtch2_test:"<<endl;
|
|
25 |
|
|
26 |
const unsigned size = 5;
|
|
27 |
char* n1[size] = { "Brett", "Graham", "Jack", "Mike", "Todd" };
|
|
28 |
int failures = 0;
|
|
29 |
char* n2[size];
|
|
30 |
copy(n1, n1 + 5, (char**)n2);
|
|
31 |
pair <char**, char**> result = mismatch((char**)n1, (char**)n1 + size, (char**)n2, str_equal);
|
|
32 |
if(result.first == n1 + size && result.second == n2 + size)
|
|
33 |
cout << "n1 and n2 are the same" << endl;
|
|
34 |
else
|
|
35 |
{
|
|
36 |
failures++;
|
|
37 |
cout << "mismatch at index: " <<(result.first - n1) << endl;
|
|
38 |
}
|
|
39 |
n2[2] = "QED";
|
|
40 |
result = mismatch((char**)n1, (char**)n1 + size, (char**)n2, str_equal);
|
|
41 |
if(result.first == n2 + size && result.second == n2 + size)
|
|
42 |
{
|
|
43 |
failures++;
|
|
44 |
cout << "n1 and n2 are the same" << endl;
|
|
45 |
}
|
|
46 |
else
|
|
47 |
cout << "mismatch at index: " <<(result.first - n1) << endl;
|
|
48 |
return failures;
|
|
49 |
}
|