31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
#include <iterator>
|
|
5 |
|
|
6 |
#include <vector>
|
|
7 |
#include <algorithm>
|
|
8 |
#include <numeric>
|
|
9 |
#include <iterator>
|
|
10 |
#include <iostream>
|
|
11 |
#include <fstream>
|
|
12 |
|
|
13 |
#ifdef MAIN
|
|
14 |
#define nextprm2_test main
|
|
15 |
#endif
|
|
16 |
int cmp(char*,char*);
|
|
17 |
|
|
18 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
19 |
using namespace std;
|
|
20 |
#endif
|
|
21 |
int nextprm2_test(int, char**)
|
|
22 |
{
|
|
23 |
cout<<"Results of nextprm2_test:"<<endl;
|
|
24 |
ofstream outfile("c:\\nextperm2.txt");
|
|
25 |
vector <char> v1(3);
|
|
26 |
iota(v1.begin(), v1.end(), 'A');
|
|
27 |
ostream_iterator<char> iter(cout);
|
|
28 |
ostream_iterator<char> iterfile(outfile);
|
|
29 |
|
|
30 |
copy(v1.begin(), v1.end(), iter);
|
|
31 |
copy(v1.begin(), v1.end(), iterfile);
|
|
32 |
cout << endl;
|
|
33 |
outfile << endl;
|
|
34 |
for(int i = 0; i < 9; i++)
|
|
35 |
{
|
|
36 |
next_permutation(v1.begin(), v1.end(), less<char>());
|
|
37 |
copy(v1.begin(), v1.end(), iter);
|
|
38 |
copy(v1.begin(), v1.end(), iterfile);
|
|
39 |
cout << endl;
|
|
40 |
outfile << endl;
|
|
41 |
}
|
|
42 |
outfile.close();
|
|
43 |
int result = cmp("c:\\nextperm2.txt","c:\\testframework\\tstdcpp\\nextperm2_good.txt");
|
|
44 |
if(result)
|
|
45 |
return 0;
|
|
46 |
else
|
|
47 |
return 1;
|
|
48 |
}
|