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