31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <iostream>
|
|
6 |
#include <vector>
|
|
7 |
#include <algorithm>
|
|
8 |
|
|
9 |
#ifdef MAIN
|
|
10 |
#define iter4_test main
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
14 |
using namespace std;
|
|
15 |
#endif
|
|
16 |
int iter4_test(int, char**)
|
|
17 |
{
|
|
18 |
cout<<"Results of iter4_test:"<<endl;
|
|
19 |
int failures = 0;
|
|
20 |
int array[2];
|
|
21 |
vector<int> v; // Empty vector of integers.
|
|
22 |
v.push_back(1);
|
|
23 |
v.push_back(2);
|
|
24 |
v.push_back(3);
|
|
25 |
// Position immediately after last item.
|
|
26 |
std::vector<int>::iterator i = v.end();
|
|
27 |
// Move back one and then access.
|
|
28 |
i -= 1;
|
|
29 |
cout << "last element is " << *i << endl;
|
|
30 |
array[0] = *i;
|
|
31 |
i -= 2; // Jump back two items.
|
|
32 |
cout << "first element is " << *i << endl;
|
|
33 |
array[1] = *i;
|
|
34 |
|
|
35 |
if(array[0] != 3)
|
|
36 |
failures++;
|
|
37 |
if(array[1] != 1)
|
|
38 |
failures++;
|
|
39 |
return failures;
|
|
40 |
}
|