ReactOS 0.4.16-dev-297-gc569aee
test_hash_map.cpp
Go to the documentation of this file.
1/***********************************************************************************
2 test_hash_map.cpp
3
4 * Copyright (c) 1997
5 * Mark of the Unicorn, Inc.
6 *
7 * Permission to use, copy, modify, distribute and sell this software
8 * and its documentation for any purpose is hereby granted without fee,
9 * provided that the above copyright notice appear in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation. Mark of the Unicorn makes no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
14
15***********************************************************************************/
16#include "Tests.h"
17#if defined( EH_HASHED_CONTAINERS_IMPLEMENTED )
18#include "TestClass.h"
19#include "LeakCheck.h"
20
21# include <hash_map>
22
23#include "test_construct.h"
24#include "test_assign_op.h"
25#include "test_push_back.h"
26#include "test_insert.h"
27#include "test_push_front.h"
28#include "ThrowCompare.h"
29#include "test_hash_resize.h"
30/*
31template struct pair<const TestClass, TestClass>;
32template struct __hashtable_node<pair<const TestClass, TestClass> >;
33template class hash_map<TestClass, TestClass, ThrowHash, ThrowEqual>;
34template class hash_multimap<TestClass, TestClass, ThrowHash, ThrowEqual>;
35*/
36
37typedef EH_STD::__hash_multimap__<TestClass, TestClass, ThrowHash, ThrowEqual,
39
40
41inline multimap_tag
43 return multimap_tag();
44}
45
47# if !(defined (_MSC_VER) && (_MSC_VER < 1100))
48 TestMultiMap testMultiMap, testMultiMap2;
49
50 const size_t hash_mapSize = random_number(random_base);
51
52 while ( testMultiMap.size() < hash_mapSize )
53 {
54 TestMultiMap::value_type x;
55 testMultiMap.insert( x );
56 testMultiMap2.insert( TestMultiMap::value_type() );
57 }
58
59# if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
61 // TestMultiMap == TestMultiMap: no such operator! - ptr
62 // StrongCheck( testMultiMap, test_insert_noresize<TestMultiMap>(testMultiMap) );
63# endif
64 WeakCheck( testMultiMap, test_insert_value<TestMultiMap>(testMultiMap) );
65
66 size_t insCnt = random_number(random_base);
67 TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[1+insCnt];
68 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) );
69 ConstCheck( 0, test_construct_pointer_range<TestMultiMap>(insFirst, insFirst+insCnt) );
70 delete[] insFirst;
71
72 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) );
73
75# if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
77# endif
79
80 WeakCheck( testMultiMap, test_assign_op<TestMultiMap>( testMultiMap2 ) );
81# endif
82}
83
84typedef EH_STD::__hash_map__<TestClass, TestClass, ThrowHash,
86
87inline map_tag
89{
90 return map_tag();
91}
92
94{
95# if !(defined (_MSC_VER) && (_MSC_VER < 1100))
96 TestMap testMap, testMap2;
97
98 const size_t hash_mapSize = random_number(random_base);
99
100 while ( testMap.size() < hash_mapSize ) {
101 TestMap::value_type x;
102 testMap.insert( x );
103 testMap2.insert( TestMap::value_type() );
104 }
105
106#if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
108 // TestMultiMap == TestMultiMap: no such operator! - ptr
109 // StrongCheck( testMap, test_insert_noresize<TestMap>(testMap) );
110#endif
111 WeakCheck( testMap, test_insert_value<TestMap>(testMap) );
112
113 size_t insCnt = random_number(random_base);
114 TestMap::value_type *insFirst = new TestMap::value_type[1+insCnt];
115 WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );
116 ConstCheck( 0, test_construct_pointer_range<TestMap>(insFirst, insFirst+insCnt) );
117 delete[] insFirst;
118
119 WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) );
120
122# if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
124# endif
126
127 WeakCheck( testMap, test_assign_op<TestMap>( testMap2 ) );
128# endif
129}
130
131#endif // EH_HASHED_CONTAINERS_IMPLEMENTED
void ConstCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:103
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
#define eh_allocator(T)
Definition: Prefix.h:174
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned random_number(size_t range)
unsigned random_base
EH_STD::__hash_map__< TestClass, TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestMap
multimap_tag container_category(const TestMultiMap &)
void test_hash_multimap()
void test_hash_map()
EH_STD::__hash_multimap__< TestClass, TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestMultiMap
test_insert_range< C, Iter > insert_range_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:535