|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // STLport regression testsuite component. |
|
19 // To compile as a separate example, please #define MAIN. |
|
20 #include <iterator> |
|
21 |
|
22 #include <vector> |
|
23 #include <algorithm> |
|
24 #include <numeric> |
|
25 #include <iterator> |
|
26 #include <iostream> |
|
27 #include <fstream> |
|
28 |
|
29 #ifdef MAIN |
|
30 #define nextprm2_test main |
|
31 #endif |
|
32 int cmp(char*,char*); |
|
33 |
|
34 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
35 using namespace std; |
|
36 #endif |
|
37 int nextprm2_test(int, char**) |
|
38 { |
|
39 cout<<"Results of nextprm2_test:"<<endl; |
|
40 ofstream outfile("c:\\nextperm2.txt"); |
|
41 vector <char> v1(3); |
|
42 iota(v1.begin(), v1.end(), 'A'); |
|
43 ostream_iterator<char> iter(cout); |
|
44 ostream_iterator<char> iterfile(outfile); |
|
45 |
|
46 copy(v1.begin(), v1.end(), iter); |
|
47 copy(v1.begin(), v1.end(), iterfile); |
|
48 cout << endl; |
|
49 outfile << endl; |
|
50 for(int i = 0; i < 9; i++) |
|
51 { |
|
52 next_permutation(v1.begin(), v1.end(), less<char>()); |
|
53 copy(v1.begin(), v1.end(), iter); |
|
54 copy(v1.begin(), v1.end(), iterfile); |
|
55 cout << endl; |
|
56 outfile << endl; |
|
57 } |
|
58 outfile.close(); |
|
59 int result = cmp("c:\\nextperm2.txt","c:\\testframework\\tstdcpp\\nextperm2_good.txt"); |
|
60 if(result) |
|
61 return 0; |
|
62 else |
|
63 return 1; |
|
64 } |