31
|
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 |
#include <iostream>
|
|
21 |
#include <map>
|
|
22 |
|
|
23 |
#ifdef MAIN
|
|
24 |
#define mmap2_test main
|
|
25 |
#endif
|
|
26 |
|
|
27 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
28 |
using namespace std;
|
|
29 |
#endif
|
|
30 |
|
|
31 |
int mmap2_test(int, char**)
|
|
32 |
{
|
|
33 |
cout<<"Results of mmap2_test:"<<endl;
|
|
34 |
//static int hook=0;
|
|
35 |
//int bb=0;
|
|
36 |
|
|
37 |
int failures = 0;
|
|
38 |
typedef pair<const int, char> pair_type;
|
|
39 |
|
|
40 |
pair_type p1(3, 'c');
|
|
41 |
pair_type p2(6, 'f');
|
|
42 |
pair_type p3(1, 'a');
|
|
43 |
pair_type p4(2, 'b');
|
|
44 |
pair_type p5(3, 'x');
|
|
45 |
pair_type p6(6, 'f');
|
|
46 |
|
|
47 |
typedef multimap<int, char, less<int> > mmap;
|
|
48 |
|
|
49 |
pair_type array [] =
|
|
50 |
{
|
|
51 |
p1,
|
|
52 |
p2,
|
|
53 |
p3,
|
|
54 |
p4,
|
|
55 |
p5,
|
|
56 |
p6
|
|
57 |
};
|
|
58 |
|
|
59 |
mmap m(array+0, array + 6);
|
|
60 |
mmap::iterator i;
|
|
61 |
i = m.lower_bound(3);
|
|
62 |
cout << "lower bound:" << endl;
|
|
63 |
cout <<(*i).first << " -> " <<(*i).second << endl;
|
|
64 |
if((*i).first != 3 && (*i).second != 'c')
|
|
65 |
failures++;
|
|
66 |
|
|
67 |
i = m.upper_bound(3);
|
|
68 |
cout << "upper bound:" << endl;
|
|
69 |
cout <<(*i).first << " -> " <<(*i).second << endl;
|
|
70 |
if((*i).first != 6 && (*i).second != 'f')
|
|
71 |
failures++;
|
|
72 |
return failures;
|
|
73 |
}
|