|
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 |
|
25 #ifdef MAIN |
|
26 #define stblsrt2_test main |
|
27 #endif |
|
28 |
|
29 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
30 using namespace std; |
|
31 #endif |
|
32 |
|
33 static bool string_less(const char* a_, const char* b_) |
|
34 { |
|
35 return strcmp(a_, b_) < 0 ? 1 : 0; |
|
36 } |
|
37 |
|
38 int stblsrt2_test(int, char**) |
|
39 { |
|
40 int failures=0; |
|
41 cout<<"Results of stblsrt2_test:"<<endl; |
|
42 |
|
43 char* letters[6] = {"bb", "aa", "ll", "dd", "qq", "cc" }; |
|
44 |
|
45 stable_sort(letters, letters + 6, string_less); |
|
46 for(int i = 0; i < 6; i++) |
|
47 cout << letters[i] << ' '; |
|
48 cout << endl; |
|
49 |
|
50 if(strcmp("aa",letters[0])!=0) |
|
51 failures++; |
|
52 else if(strcmp("bb",letters[1])!=0) |
|
53 failures++; |
|
54 else if(strcmp("cc",letters[2])!=0) |
|
55 failures++; |
|
56 else if(strcmp("dd",letters[3])!=0) |
|
57 failures++; |
|
58 else if(strcmp("ll",letters[4])!=0) |
|
59 failures++; |
|
60 else if(strcmp("qq",letters[5])!=0) |
|
61 failures++; |
|
62 |
|
63 if(failures) |
|
64 return 1; |
|
65 else |
|
66 return 0; |
|
67 } |
|
68 |