|
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 |
|
21 #include <iostream> |
|
22 #include <list> |
|
23 |
|
24 #ifdef MAIN |
|
25 #define list3_test main |
|
26 #endif |
|
27 |
|
28 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
29 using namespace std; |
|
30 #endif |
|
31 int list3_test(int, char**) |
|
32 { |
|
33 cout<<"Results of list3_test:"<<endl; |
|
34 char array [] = { 'x', 'l', 'x', 't', 's', 's' }; |
|
35 char array1[7]; |
|
36 //char array2[] = {'s','s','t','x','l','x'}; |
|
37 //char array3[] = {'s','s','t','l'}; |
|
38 //char array4[] = {'s','t','l'}; |
|
39 //char array5[] = {'l','s','t'}; |
|
40 |
|
41 int a =0,failures = 0; |
|
42 |
|
43 list<char> str(array, array + 6); |
|
44 std::list<char>::iterator i; |
|
45 cout << "original: "; |
|
46 for(i = str.begin(); i != str.end(); i++) |
|
47 { |
|
48 array1[a++]=*i; |
|
49 cout << *i; |
|
50 } |
|
51 |
|
52 array1[a] = '\0'; |
|
53 cout << endl; |
|
54 |
|
55 if(array1[0] != 'x') |
|
56 failures++; |
|
57 if(array1[1] != 'l') |
|
58 failures++; |
|
59 if(array1[2] != 'x') |
|
60 failures++; |
|
61 if(array1[3] != 't') |
|
62 failures++; |
|
63 if(array1[4] != 's') |
|
64 failures++; |
|
65 if(array1[5] != 's') |
|
66 failures++; |
|
67 |
|
68 |
|
69 a=0; |
|
70 cout << "reversed: "; |
|
71 str.reverse(); |
|
72 for(i = str.begin(); i != str.end(); i++) |
|
73 { |
|
74 array1[a++]=*i; |
|
75 cout << *i; |
|
76 } |
|
77 array1[a] = '\0'; |
|
78 cout << endl; |
|
79 if(array1[0] != 's') |
|
80 failures++; |
|
81 if(array1[1] != 's') |
|
82 failures++; |
|
83 if(array1[2] != 't') |
|
84 failures++; |
|
85 if(array1[3] != 'x') |
|
86 failures++; |
|
87 if(array1[4] != 'l') |
|
88 failures++; |
|
89 if(array1[5] != 'x') |
|
90 failures++; |
|
91 |
|
92 a=0; |
|
93 cout << "removed: "; |
|
94 str.remove('x'); |
|
95 for(i = str.begin(); i != str.end(); i++) |
|
96 { |
|
97 array1[a++]=*i; |
|
98 cout << *i; |
|
99 } |
|
100 array1[a] = '\0'; |
|
101 cout << endl; |
|
102 if(array1[0] != 's') |
|
103 failures++; |
|
104 if(array1[1] != 's') |
|
105 failures++; |
|
106 if(array1[2] != 't') |
|
107 failures++; |
|
108 if(array1[3] != 'l') |
|
109 failures++; |
|
110 |
|
111 a=0; |
|
112 cout << "uniqued: "; |
|
113 str.unique(); |
|
114 for(i = str.begin(); i != str.end(); i++) |
|
115 { |
|
116 array1[a++]=*i; |
|
117 cout << *i; |
|
118 } |
|
119 array1[a] = '\0'; |
|
120 cout << endl; |
|
121 if(array1[0] != 's') |
|
122 failures++; |
|
123 if(array1[1] != 't') |
|
124 failures++; |
|
125 if(array1[2] != 'l') |
|
126 failures++; |
|
127 |
|
128 a=0; |
|
129 cout << "sorted: "; |
|
130 str.sort(); |
|
131 for(i = str.begin(); i != str.end(); i++) |
|
132 { |
|
133 array1[a++]=*i; |
|
134 cout << *i; |
|
135 } |
|
136 array1[a] = '\0'; |
|
137 cout << endl; |
|
138 if(array1[0] != 'l') |
|
139 failures++; |
|
140 if(array1[1] != 's') |
|
141 failures++; |
|
142 if(array1[2] != 't') |
|
143 failures++; |
|
144 |
|
145 return failures; |
|
146 } |