1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/eh/test_set.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,100 @@
1.4 +/***********************************************************************************
1.5 + test_set.cpp
1.6 +
1.7 + * Copyright (c) 1997
1.8 + * Mark of the Unicorn, Inc.
1.9 + *
1.10 + * Permission to use, copy, modify, distribute and sell this software
1.11 + * and its documentation for any purpose is hereby granted without fee,
1.12 + * provided that the above copyright notice appear in all copies and
1.13 + * that both that copyright notice and this permission notice appear
1.14 + * in supporting documentation. Mark of the Unicorn makes no
1.15 + * representations about the suitability of this software for any
1.16 + * purpose. It is provided "as is" without express or implied warranty.
1.17 +
1.18 +***********************************************************************************/
1.19 +#include "Tests.h"
1.20 +#include "TestClass.h"
1.21 +#include "LeakCheck.h"
1.22 +#if defined (EH_NEW_HEADERS)
1.23 +# include <set>
1.24 +#else
1.25 +# include <multiset.h>
1.26 +# include <set.h>
1.27 +#endif
1.28 +#include "test_construct.h"
1.29 +#include "test_assign_op.h"
1.30 +#include "test_push_back.h"
1.31 +#include "test_insert.h"
1.32 +#include "test_push_front.h"
1.33 +#include "ThrowCompare.h"
1.34 +
1.35 +void test_multiset();
1.36 +
1.37 +typedef EH_STD::__multiset__<TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiSet;
1.38 +
1.39 +inline multiset_tag
1.40 +container_category(const TestMultiSet&) {
1.41 + return multiset_tag();
1.42 +}
1.43 +
1.44 +void test_multiset() {
1.45 + TestMultiSet testMultiSet, testMultiSet2;
1.46 +
1.47 + const size_t setSize = random_number(random_base);
1.48 +
1.49 + while (testMultiSet.size() < setSize) {
1.50 + TestMultiSet::value_type x;
1.51 + testMultiSet.insert( x );
1.52 + testMultiSet2.insert( TestMultiSet::value_type() );
1.53 + }
1.54 +
1.55 + StrongCheck( testMultiSet, test_insert_value<TestMultiSet>(testMultiSet) );
1.56 +
1.57 + size_t insCnt = random_number(random_base);
1.58 + TestMultiSet::value_type *insFirst = new TestMultiSet::value_type[1+insCnt];
1.59 + WeakCheck( testMultiSet, insert_range_tester(testMultiSet, insFirst, insFirst+insCnt) );
1.60 + ConstCheck( 0, test_construct_pointer_range<TestMultiSet>(insFirst, insFirst+insCnt) );
1.61 + delete[] insFirst;
1.62 + WeakCheck( testMultiSet, insert_range_tester(testMultiSet, testMultiSet2.begin(), testMultiSet2.end() ) );
1.63 +
1.64 + ConstCheck( 0, test_default_construct<TestMultiSet>() );
1.65 + ConstCheck( 0, test_construct_iter_range<TestMultiSet>( testMultiSet2 ) );
1.66 + ConstCheck( testMultiSet, test_copy_construct<TestMultiSet>() );
1.67 +
1.68 + WeakCheck( testMultiSet, test_assign_op<TestMultiSet>( testMultiSet2 ) );
1.69 +}
1.70 +
1.71 +typedef EH_STD::__set__<TestClass, ThrowCompare, eh_allocator(TestClass) > TestSet;
1.72 +
1.73 +inline set_tag
1.74 +container_category(const TestSet&) {
1.75 + return set_tag();
1.76 +}
1.77 +
1.78 +void test_set() {
1.79 + TestSet testSet, testSet2;
1.80 +
1.81 + const size_t setSize = random_number(random_base);
1.82 +
1.83 + while ( testSet.size() < setSize ) {
1.84 + TestSet::value_type x;
1.85 + testSet.insert( x );
1.86 + testSet2.insert( TestSet::value_type() );
1.87 + }
1.88 + StrongCheck( testSet, test_insert_value<TestSet>(testSet) );
1.89 +
1.90 + size_t insCnt = random_number(random_base);
1.91 + TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt];
1.92 +
1.93 + WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) );
1.94 +
1.95 + ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) );
1.96 + delete[] insFirst;
1.97 + WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) );
1.98 +
1.99 + ConstCheck( 0, test_default_construct<TestSet>() );
1.100 + ConstCheck( 0, test_construct_iter_range<TestSet>( testSet2 ) );
1.101 + ConstCheck( testSet, test_copy_construct<TestSet>() );
1.102 + WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) );
1.103 +}