31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <iostream>
|
|
6 |
#include <hash_set>
|
|
7 |
|
|
8 |
#ifdef MAIN
|
|
9 |
#define hmset1_test main
|
|
10 |
#endif
|
|
11 |
|
|
12 |
|
|
13 |
// struct hash<string> {
|
|
14 |
// size_t operator()(const string& s) const { return __stl_hash_string(s.c_str()); }
|
|
15 |
//};
|
|
16 |
|
|
17 |
#if defined (__MVS__)
|
|
18 |
#define star 92
|
|
19 |
#else
|
|
20 |
#define star 42
|
|
21 |
|
|
22 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
23 |
using namespace std;
|
|
24 |
#endif
|
|
25 |
#endif
|
|
26 |
|
|
27 |
typedef hash_multiset<char, hash<char>, equal_to<char> > hmset;
|
|
28 |
// __STL_TYPE_TRAITS_POD_SPECIALIZE(_Hashtable_node<char>*);
|
|
29 |
|
|
30 |
|
|
31 |
int hmset1_test(int, char**)
|
|
32 |
{
|
|
33 |
cout<< "Results of hmset1_test:"<<endl;
|
|
34 |
|
|
35 |
hmset s;
|
|
36 |
int failures = 0;
|
|
37 |
cout << "count(" << star << ") = " << s.count(star) << endl;
|
|
38 |
if(s.count(star) != 0)
|
|
39 |
failures++;
|
|
40 |
|
|
41 |
s.insert(star);
|
|
42 |
cout << "count(" << star << ") = " << s.count(star) << endl;
|
|
43 |
if(s.count(star) != 1)
|
|
44 |
failures++;
|
|
45 |
|
|
46 |
s.insert(star);
|
|
47 |
cout << "count(" << star << ") = " << s.count(star) << endl;
|
|
48 |
if(s.count(star) != 2)
|
|
49 |
failures++;
|
|
50 |
|
|
51 |
hmset::iterator i = s.find(40);
|
|
52 |
if(i == s.end())
|
|
53 |
{
|
|
54 |
cout << "40 Not found" << endl;
|
|
55 |
}
|
|
56 |
else
|
|
57 |
{
|
|
58 |
cout << "Found " << *i << endl;
|
|
59 |
failures++;
|
|
60 |
}
|
|
61 |
i = s.find(star);
|
|
62 |
if(i == s.end())
|
|
63 |
{
|
|
64 |
cout << "Not found" << endl;
|
|
65 |
failures++;
|
|
66 |
}
|
|
67 |
else
|
|
68 |
{
|
|
69 |
cout << "Found " << *i << endl;
|
|
70 |
}
|
|
71 |
|
|
72 |
int count = s.erase(star);
|
|
73 |
cout << "Erased " << count << " instances" << endl;
|
|
74 |
if(count != 2)
|
|
75 |
failures++;
|
|
76 |
|
|
77 |
if (!failures)
|
|
78 |
return 0;
|
|
79 |
else
|
|
80 |
return 1;
|
|
81 |
}
|