|
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 <algorithm> |
|
22 #include <iostream> |
|
23 #include <cstring> |
|
24 #include <iterator> |
|
25 #include <functional> |
|
26 |
|
27 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
28 using namespace std; |
|
29 #endif |
|
30 |
|
31 #ifdef MAIN |
|
32 #define unique2_test main |
|
33 #endif |
|
34 static bool str_equal(const char* a_, const char* b_) |
|
35 { |
|
36 return strcmp(a_, b_) == 0 ? 1 : 0; |
|
37 } |
|
38 |
|
39 int unique2_test(int, char**) |
|
40 { |
|
41 |
|
42 int failures=0; |
|
43 cout<<"Results of unique2_test:"<<endl; |
|
44 |
|
45 char* labels[] = { "Q","Q","W","W","E","E","R","T","T","Y","Y" }; |
|
46 |
|
47 char* arr[12]; |
|
48 const unsigned count = sizeof(labels) / sizeof(labels[0]); |
|
49 ostream_iterator <char*> iter(cout); |
|
50 |
|
51 copy((char**)labels, (char**)labels + count, (char**)arr); |
|
52 |
|
53 if(str_equal(arr[0],"Q")!=1) |
|
54 failures++; |
|
55 else if(str_equal(arr[1],"Q")!=1) |
|
56 failures++; |
|
57 else if(str_equal(arr[2],"W")!=1) |
|
58 failures++; |
|
59 else if(str_equal(arr[3],"W")!=1) |
|
60 failures++; |
|
61 else if(str_equal(arr[4],"E")!=1) |
|
62 failures++; |
|
63 else if(str_equal(arr[5],"E")!=1) |
|
64 failures++; |
|
65 else if(str_equal(arr[6],"R")!=1) |
|
66 failures++; |
|
67 else if(str_equal(arr[7],"T")!=1) |
|
68 failures++; |
|
69 else if(str_equal(arr[8],"T")!=1) |
|
70 failures++; |
|
71 else if(str_equal(arr[9],"Y")!=1) |
|
72 failures++; |
|
73 else if(str_equal(arr[10],"Y")!=1) |
|
74 failures++; |
|
75 |
|
76 copy((char**)arr,(char**)arr +10 ,iter); |
|
77 cout << endl; |
|
78 unique((char**)labels, (char**)labels + count, str_equal); |
|
79 copy((char**)labels, (char**)labels + count, (char**)arr); |
|
80 |
|
81 if(str_equal(arr[0],"Q")!=1) |
|
82 failures++; |
|
83 else if(str_equal(arr[1],"W")!=1) |
|
84 failures++; |
|
85 else if(str_equal(arr[2],"E")!=1) |
|
86 failures++; |
|
87 else if(str_equal(arr[3],"R")!=1) |
|
88 failures++; |
|
89 else if(str_equal(arr[4],"T")!=1) |
|
90 failures++; |
|
91 else if(str_equal(arr[5],"Y")!=1) |
|
92 failures++; |
|
93 else if(str_equal(arr[6],"R")!=1) |
|
94 failures++; |
|
95 else if(str_equal(arr[7],"T")!=1) |
|
96 failures++; |
|
97 else if(str_equal(arr[8],"T")!=1) |
|
98 failures++; |
|
99 else if(str_equal(arr[9],"Y")!=1) |
|
100 failures++; |
|
101 else if(str_equal(arr[10],"Y")!=1) |
|
102 failures++; |
|
103 |
|
104 copy((char**)arr,(char**)arr +10 ,iter); |
|
105 |
|
106 cout << endl; |
|
107 |
|
108 if(failures) |
|
109 return 1; |
|
110 else |
|
111 return 0; |
|
112 } |
|
113 |
|
114 /*QQWWEERTTYY |
|
115 QWERTYRTTYY*/ |