ReactOS 0.4.15-dev-7918-g2a2556c
test_map.cpp
Go to the documentation of this file.
1/***********************************************************************************
2 test_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#include "TestClass.h"
18#include "LeakCheck.h"
19# if defined (EH_NEW_HEADERS)
20#include <map>
21# else
22#include <multimap.h>
23#include <map.h>
24# endif
25
26#include "test_construct.h"
27#include "test_assign_op.h"
28#include "test_push_back.h"
29#include "test_insert.h"
30#include "test_push_front.h"
31#include "ThrowCompare.h"
32#include "test_insert.h"
33
34template <class K, class V, class Comp, class A>
35inline multimap_tag
36container_category(const EH_STD::__multimap__<K,V,Comp, A>&)
37{
38 return multimap_tag();
39}
40
41template <class K, class V, class Comp, class A >
42inline map_tag
43container_category(const EH_STD::__map__<K,V,Comp, A>&)
44{
45 return map_tag();
46}
47
49
51{
52 TestMultiMap testMultiMap, testMultiMap2;
53
54 const size_t mapSize = random_number(random_base);
55
56 while ( testMultiMap.size() < mapSize )
57 {
58 TestMultiMap::value_type x;
59 testMultiMap.insert( x );
60 testMultiMap2.insert( TestMultiMap::value_type() );
61 }
62
63 StrongCheck( testMultiMap, test_insert_value<TestMultiMap>(testMultiMap) );
64
65 size_t insCnt = 1 + random_number(random_base);
66 TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[insCnt];
67
68 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) );
69
70 ConstCheck( 0, test_construct_pointer_range<TestMultiMap>(insFirst, insFirst+insCnt) );
71 delete[] insFirst;
72
73
74 WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) );
75
76
78
80
82
83 WeakCheck( testMultiMap, test_assign_op<TestMultiMap>( testMultiMap2 ) );
84}
85
87
88void CheckInvariant( const TestMap& m );
89
90void CheckInvariant( const TestMap& m )
91{
92// assert( map.__rb_verify() );
93 size_t total = 0;
94 EH_DISTANCE( m.begin(), m.end(), total );
95 assert( m.size() == total );
96}
97
99{
100 TestMap testMap, testMap2;
101
102 const size_t mapSize = random_number(random_base);
103
104 while ( testMap.size() < mapSize )
105 {
106 TestMap::value_type x;
107 testMap.insert( x );
108 testMap2.insert( TestMap::value_type() );
109 }
110
111 StrongCheck( 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
116 WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );
117
118 ConstCheck( 0, test_construct_pointer_range<TestMap>(insFirst, insFirst+insCnt) );
119 delete[] insFirst;
120
121 WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) );
125 WeakCheck( testMap, test_assign_op<TestMap>( testMap2 ) );
126}
127
void ConstCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:103
void StrongCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:145
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
#define eh_allocator(T)
Definition: Prefix.h:174
#define EH_DISTANCE(a, b, result)
Definition: Prefix.h:98
#define assert(x)
Definition: debug.h:53
size_t total
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLfloat * m
Definition: glext.h:10848
unsigned random_number(size_t range)
unsigned random_base
EH_STD::__hash_map__< TestClass, TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestMap
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
EH_STD::__multimap__< TestClass, TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiMap
Definition: test_map.cpp:48
void test_multimap()
Definition: test_map.cpp:50
void CheckInvariant(const TestMap &m)
Definition: test_map.cpp:90
void test_map()
Definition: test_map.cpp:98
EH_STD::__map__< TestClass, TestClass, ThrowCompare, eh_allocator(TestClass) > TestMap
Definition: test_map.cpp:86
multimap_tag container_category(const EH_STD::__multimap__< K, V, Comp, A > &)
Definition: test_map.cpp:36