ReactOS  0.4.13-dev-79-gcd489d8
test_set.cpp
Go to the documentation of this file.
1 /***********************************************************************************
2  test_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 #include "TestClass.h"
18 #include "LeakCheck.h"
19 #if defined (EH_NEW_HEADERS)
20 # include <set>
21 #else
22 # include <multiset.h>
23 # include <set.h>
24 #endif
25 #include "test_construct.h"
26 #include "test_assign_op.h"
27 #include "test_push_back.h"
28 #include "test_insert.h"
29 #include "test_push_front.h"
30 #include "ThrowCompare.h"
31 
32 void test_multiset();
33 
35 
36 inline multiset_tag
38  return multiset_tag();
39 }
40 
41 void test_multiset() {
42  TestMultiSet testMultiSet, testMultiSet2;
43 
44  const size_t setSize = random_number(random_base);
45 
46  while (testMultiSet.size() < setSize) {
47  TestMultiSet::value_type x;
48  testMultiSet.insert( x );
49  testMultiSet2.insert( TestMultiSet::value_type() );
50  }
51 
52  StrongCheck( testMultiSet, test_insert_value<TestMultiSet>(testMultiSet) );
53 
54  size_t insCnt = random_number(random_base);
55  TestMultiSet::value_type *insFirst = new TestMultiSet::value_type[1+insCnt];
56  WeakCheck( testMultiSet, insert_range_tester(testMultiSet, insFirst, insFirst+insCnt) );
57  ConstCheck( 0, test_construct_pointer_range<TestMultiSet>(insFirst, insFirst+insCnt) );
58  delete[] insFirst;
59  WeakCheck( testMultiSet, insert_range_tester(testMultiSet, testMultiSet2.begin(), testMultiSet2.end() ) );
60 
64 
65  WeakCheck( testMultiSet, test_assign_op<TestMultiSet>( testMultiSet2 ) );
66 }
67 
69 
70 inline set_tag
72  return set_tag();
73 }
74 
75 void test_set() {
76  TestSet testSet, testSet2;
77 
78  const size_t setSize = random_number(random_base);
79 
80  while ( testSet.size() < setSize ) {
81  TestSet::value_type x;
82  testSet.insert( x );
83  testSet2.insert( TestSet::value_type() );
84  }
86 
87  size_t insCnt = random_number(random_base);
88  TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt];
89 
90  WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) );
91 
92  ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) );
93  delete[] insFirst;
94  WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) );
95 
100 }
multiset_tag container_category(const TestMultiSet &)
Definition: test_set.cpp:37
void test_multiset()
Definition: test_set.cpp:41
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
EH_STD::__hash_multiset__< TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestMultiSet
test_insert_range< C, Iter > insert_range_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:535
#define __set__
EH_STD::__multiset__< TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiSet
Definition: test_set.cpp:34
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
EH_STD::__set__< TestClass, ThrowCompare, eh_allocator(TestClass) > TestSet
Definition: test_set.cpp:68
unsigned random_number(size_t range)
void test_set()
Definition: test_set.cpp:75
#define __multiset__
#define eh_allocator(T)
Definition: Prefix.h:174
void StrongCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:145