31
|
1 |
|
|
2 |
|
|
3 |
// STLport regression testsuite component.
|
|
4 |
// To compile as a separate example, please #define MAIN.
|
|
5 |
|
|
6 |
#include <algorithm>
|
|
7 |
#include <iostream>
|
|
8 |
#include <cstring>
|
|
9 |
|
|
10 |
#ifdef MAIN
|
|
11 |
#define uprbnd2_test main
|
|
12 |
#endif
|
|
13 |
|
|
14 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
15 |
using namespace std;
|
|
16 |
#endif
|
|
17 |
|
|
18 |
static bool char_str_less(const char* a_, const char* b_)
|
|
19 |
{
|
|
20 |
return strcmp(a_, b_) < 0 ? 1 : 0;
|
|
21 |
}
|
|
22 |
|
|
23 |
int uprbnd2_test(int, char**)
|
|
24 |
{
|
|
25 |
int x=0;
|
|
26 |
cout<<"Results of uprbnd2_test:"<<endl;
|
|
27 |
|
|
28 |
char* str [] = { "a", "a", "b", "b", "q", "w", "z" };
|
|
29 |
|
|
30 |
const unsigned strCt = sizeof(str)/sizeof(str[0]);
|
|
31 |
// DEC C++ generates incorrect template instatiation code
|
|
32 |
// for "d" so must cast
|
|
33 |
|
|
34 |
x=(upper_bound((char**)str, (char**)str + strCt, (const char *)"d", char_str_less) - str);
|
|
35 |
|
|
36 |
cout<< "d can be inserted at index: "<<x<<endl;
|
|
37 |
|
|
38 |
|
|
39 |
if(4!=x)
|
|
40 |
return 1;
|
|
41 |
else
|
|
42 |
return 0;
|
|
43 |
}
|
|
44 |
|
|
45 |
|