ReactOS  0.4.13-dev-257-gfabbd7c
test_hash_set.cpp
Go to the documentation of this file.
1 /***********************************************************************************
2  test_hash_set.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 
18 #if defined( EH_HASHED_CONTAINERS_IMPLEMENTED )
19 
20 # include <hash_set>
21 
22 #include "TestClass.h"
23 #include "LeakCheck.h"
24 #include "test_construct.h"
25 #include "test_assign_op.h"
26 #include "test_push_back.h"
27 #include "test_insert.h"
28 #include "test_push_front.h"
29 #include "ThrowCompare.h"
30 #include "test_hash_resize.h"
31 
34 
35 inline multiset_tag
37 {
38  return multiset_tag();
39 }
40 
42 {
43 # if !(defined (_MSC_VER) && (_MSC_VER < 1100))
44  TestMultiSet testMultiSet, testMultiSet2;
45 
46  const size_t hash_setSize = random_number(random_base);
47 
48  while ( testMultiSet.size() < hash_setSize )
49  {
50  TestMultiSet::value_type x;
51  testMultiSet.insert( x );
52  testMultiSet2.insert( TestMultiSet::value_type() );
53  }
54 
55 # if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
56  WeakCheck( testMultiSet, test_hash_resize<TestMultiSet>() );
57  // TestMultiSet == TestMultiSet: no such operator! - ptr
58  // StrongCheck( testMultiSet, test_insert_noresize<TestMultiSet>(testMultiSet) );
59 # endif
60  WeakCheck( testMultiSet, test_insert_value<TestMultiSet>(testMultiSet) );
61 
62  size_t insCnt = random_number(random_base);
63  TestMultiSet::value_type *insFirst = new TestMultiSet::value_type[1+insCnt];
64  WeakCheck( testMultiSet, insert_range_tester(testMultiSet, insFirst, insFirst+insCnt) );
65  ConstCheck( 0, test_construct_pointer_range<TestMultiSet>(insFirst, insFirst+insCnt) );
66  delete[] insFirst;
67 
68  WeakCheck( testMultiSet, insert_range_tester(testMultiSet, testMultiSet2.begin(), testMultiSet2.end() ) );
69 
71 # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
73 # endif
75 
76  WeakCheck( testMultiSet, test_assign_op<TestMultiSet>( testMultiSet2 ) );
77 # endif
78 }
79 
81 
82 inline set_tag
84 {
85  return set_tag();
86 }
87 
89 {
90 # if !(defined (_MSC_VER) && (_MSC_VER < 1100))
91  TestSet testSet, testSet2;
92 
93  const size_t hash_setSize = random_number(random_base);
94 
95  while ( testSet.size() < hash_setSize )
96  {
97  TestSet::value_type x;
98  testSet.insert( x );
99  testSet2.insert( TestSet::value_type() );
100  }
101 
102 # if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
104  // TestMultiSet == TestMultiSet: no such operator! - ptr
105  // StrongCheck( testSet, test_insert_noresize<TestSet>(testSet) );
106 # endif
108 
109  size_t insCnt = random_number(random_base);
110  TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt];
111  WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) );
112  ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) );
113  delete[] insFirst;
114 
115  WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) );
116 
118 # if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
120 # endif
122 
123  WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) );
124 # endif
125 }
126 
127 #endif // EH_HASHED_CONTAINERS_IMPLEMENTED
void test_hash_set()
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
#define __hash_set__
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
EH_STD::__hash_multiset__< TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestMultiSet
multiset_tag container_category(const TestMultiSet &)
#define __hash_multiset__
test_insert_range< C, Iter > insert_range_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:535
EH_STD::__hash_set__< TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestSet
void ConstCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:103
unsigned random_base
static void testSet(void)
Definition: env.c:170
void test_hash_multiset()
unsigned random_number(size_t range)
#define eh_allocator(T)
Definition: Prefix.h:174