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 |
|
|
8 |
|
|
9 |
#ifdef MAIN
|
|
10 |
#define adjfind0_test main
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
14 |
using namespace std;
|
|
15 |
#endif
|
|
16 |
int adjfind0_test(int, char**)
|
|
17 |
{
|
|
18 |
|
|
19 |
cout<<"Results of adjfind0_test:"<<endl;
|
|
20 |
int numbers1 [5] = { 1, 2, 4, 8, 16 };
|
|
21 |
int numbers2 [5] = { 5, 3, 2, 1, 1 };
|
|
22 |
|
|
23 |
int failures = 0;
|
|
24 |
int* location = adjacent_find((int*)numbers1, (int*)numbers1 + 5);
|
|
25 |
|
|
26 |
if(location != numbers1 + 5)
|
|
27 |
{
|
|
28 |
cout
|
|
29 |
<< "Found adjacent pair of: "
|
|
30 |
<< *location
|
|
31 |
<< " at offset "
|
|
32 |
<<(location - numbers1)
|
|
33 |
<< endl;
|
|
34 |
failures++;
|
|
35 |
}
|
|
36 |
else
|
|
37 |
{
|
|
38 |
cout << "No adjacent pairs" << endl;
|
|
39 |
}
|
|
40 |
|
|
41 |
location = adjacent_find((int*)numbers2, (int*)numbers2 + 5);
|
|
42 |
if(location != numbers2 + 5)
|
|
43 |
{
|
|
44 |
cout
|
|
45 |
<< "Found adjacent pair of: "
|
|
46 |
<< *location
|
|
47 |
<< " at offset "
|
|
48 |
<<(location - numbers2)
|
|
49 |
<< endl;
|
|
50 |
if (*location != 1)
|
|
51 |
failures++;
|
|
52 |
}
|
|
53 |
else
|
|
54 |
{
|
|
55 |
cout << "No adjacent pairs" << endl;
|
|
56 |
failures++;
|
|
57 |
}
|
|
58 |
|
|
59 |
if (!failures)
|
|
60 |
return 0;
|
|
61 |
else
|
|
62 |
return 1;
|
|
63 |
}
|