31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <algorithm>
|
|
6 |
#include <iostream>
|
|
7 |
#include <cstring>
|
|
8 |
|
|
9 |
#ifdef MAIN
|
|
10 |
#define stblsrt2_test main
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
14 |
using namespace std;
|
|
15 |
#endif
|
|
16 |
|
|
17 |
static bool string_less(const char* a_, const char* b_)
|
|
18 |
{
|
|
19 |
return strcmp(a_, b_) < 0 ? 1 : 0;
|
|
20 |
}
|
|
21 |
|
|
22 |
int stblsrt2_test(int, char**)
|
|
23 |
{
|
|
24 |
int failures=0;
|
|
25 |
cout<<"Results of stblsrt2_test:"<<endl;
|
|
26 |
|
|
27 |
char* letters[6] = {"bb", "aa", "ll", "dd", "qq", "cc" };
|
|
28 |
|
|
29 |
stable_sort(letters, letters + 6, string_less);
|
|
30 |
for(int i = 0; i < 6; i++)
|
|
31 |
cout << letters[i] << ' ';
|
|
32 |
cout << endl;
|
|
33 |
|
|
34 |
if(strcmp("aa",letters[0])!=0)
|
|
35 |
failures++;
|
|
36 |
else if(strcmp("bb",letters[1])!=0)
|
|
37 |
failures++;
|
|
38 |
else if(strcmp("cc",letters[2])!=0)
|
|
39 |
failures++;
|
|
40 |
else if(strcmp("dd",letters[3])!=0)
|
|
41 |
failures++;
|
|
42 |
else if(strcmp("ll",letters[4])!=0)
|
|
43 |
failures++;
|
|
44 |
else if(strcmp("qq",letters[5])!=0)
|
|
45 |
failures++;
|
|
46 |
|
|
47 |
if(failures)
|
|
48 |
return 1;
|
|
49 |
else
|
|
50 |
return 0;
|
|
51 |
}
|
|
52 |
|