ReactOS 0.4.16-dev-297-gc569aee
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
32void test_multiset();
33
34typedef EH_STD::__multiset__<TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiSet;
35
36inline multiset_tag
38 return multiset_tag();
39}
40
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
70inline set_tag
72 return set_tag();
73}
74
75void 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}
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
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static void testSet(void)
Definition: env.c:170
unsigned random_number(size_t range)
unsigned random_base
EH_STD::__hash_multiset__< TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestMultiSet
EH_STD::__hash_set__< TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestSet
test_insert_range< C, Iter > insert_range_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:535
EH_STD::__set__< TestClass, ThrowCompare, eh_allocator(TestClass) > TestSet
Definition: test_set.cpp:68
multiset_tag container_category(const TestMultiSet &)
Definition: test_set.cpp:37
EH_STD::__multiset__< TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiSet
Definition: test_set.cpp:34
void test_multiset()
Definition: test_set.cpp:41
void test_set()
Definition: test_set.cpp:75