31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
#include <iostream>
|
|
5 |
#include <map>
|
|
6 |
|
|
7 |
#ifdef MAIN
|
|
8 |
#define mmap2_test main
|
|
9 |
#endif
|
|
10 |
|
|
11 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
12 |
using namespace std;
|
|
13 |
#endif
|
|
14 |
|
|
15 |
int mmap2_test(int, char**)
|
|
16 |
{
|
|
17 |
cout<<"Results of mmap2_test:"<<endl;
|
|
18 |
//static int hook=0;
|
|
19 |
//int bb=0;
|
|
20 |
|
|
21 |
int failures = 0;
|
|
22 |
typedef pair<const int, char> pair_type;
|
|
23 |
|
|
24 |
pair_type p1(3, 'c');
|
|
25 |
pair_type p2(6, 'f');
|
|
26 |
pair_type p3(1, 'a');
|
|
27 |
pair_type p4(2, 'b');
|
|
28 |
pair_type p5(3, 'x');
|
|
29 |
pair_type p6(6, 'f');
|
|
30 |
|
|
31 |
typedef multimap<int, char, less<int> > mmap;
|
|
32 |
|
|
33 |
pair_type array [] =
|
|
34 |
{
|
|
35 |
p1,
|
|
36 |
p2,
|
|
37 |
p3,
|
|
38 |
p4,
|
|
39 |
p5,
|
|
40 |
p6
|
|
41 |
};
|
|
42 |
|
|
43 |
mmap m(array+0, array + 6);
|
|
44 |
mmap::iterator i;
|
|
45 |
i = m.lower_bound(3);
|
|
46 |
cout << "lower bound:" << endl;
|
|
47 |
cout <<(*i).first << " -> " <<(*i).second << endl;
|
|
48 |
if((*i).first != 3 && (*i).second != 'c')
|
|
49 |
failures++;
|
|
50 |
|
|
51 |
i = m.upper_bound(3);
|
|
52 |
cout << "upper bound:" << endl;
|
|
53 |
cout <<(*i).first << " -> " <<(*i).second << endl;
|
|
54 |
if((*i).first != 6 && (*i).second != 'f')
|
|
55 |
failures++;
|
|
56 |
return failures;
|
|
57 |
}
|