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 |
|
|
21 |
#include <map>
|
|
22 |
#include <iostream>
|
|
23 |
|
|
24 |
#ifdef MAIN
|
|
25 |
#define mmap1_test main
|
|
26 |
#endif
|
|
27 |
|
|
28 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
29 |
using namespace std;
|
|
30 |
#endif
|
|
31 |
int mmap1_test(int, char**)
|
|
32 |
{
|
|
33 |
cout<<"Results of mmap1_test:"<<endl;
|
|
34 |
typedef multimap<char, int, less<char> > mmap;
|
|
35 |
mmap m;
|
|
36 |
int failures = 0;
|
|
37 |
|
|
38 |
cout << "count('X') = " << m.count('X') << endl;
|
|
39 |
if(m.count('X') != 0)
|
|
40 |
failures++;
|
|
41 |
|
|
42 |
m.insert(pair<const char, int>('X', 10)); // Standard way.
|
|
43 |
cout << "count('X') = " << m.count('X') << endl;
|
|
44 |
// m.insert('X', 20); // Non-standard, but very convenient!
|
|
45 |
if(m.count('X') != 1)
|
|
46 |
failures++;
|
|
47 |
|
|
48 |
m.insert(pair<const char, int>('X', 20)); // jbuck: standard way
|
|
49 |
cout << "count('X') = " << m.count('X') << endl;
|
|
50 |
// m.insert('Y', 32);
|
|
51 |
if(m.count('X') != 2)
|
|
52 |
failures++;
|
|
53 |
m.insert(pair<const char, int>('Y', 32)); // jbuck: standard way
|
|
54 |
mmap::iterator i = m.find('X'); // Find first match.
|
|
55 |
while(i != m.end()) // Loop until end is reached.
|
|
56 |
{
|
|
57 |
cout <<(*i).first << " -> " <<(*i).second << endl;
|
|
58 |
i++;
|
|
59 |
}
|
|
60 |
int count = m.erase('X');
|
|
61 |
cout << "Erased " << count << " items" << endl;
|
|
62 |
if (count != 2)
|
|
63 |
failures++;
|
|
64 |
|
|
65 |
return failures;
|
|
66 |
}
|