Home | History | Annotate | Download | only in eh
      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 
     34 typedef EH_STD::__multiset__<TestClass, ThrowCompare, eh_allocator(TestClass) > TestMultiSet;
     35 
     36 inline multiset_tag
     37 container_category(const TestMultiSet&) {
     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 
     61   ConstCheck( 0, test_default_construct<TestMultiSet>() );
     62   ConstCheck( 0, test_construct_iter_range<TestMultiSet>( testMultiSet2 ) );
     63   ConstCheck( testMultiSet, test_copy_construct<TestMultiSet>() );
     64 
     65   WeakCheck( testMultiSet, test_assign_op<TestMultiSet>( testMultiSet2 ) );
     66 }
     67 
     68 typedef EH_STD::__set__<TestClass, ThrowCompare, eh_allocator(TestClass) > TestSet;
     69 
     70 inline set_tag
     71 container_category(const TestSet&) {
     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   }
     85   StrongCheck( testSet, test_insert_value<TestSet>(testSet) );
     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 
     96   ConstCheck( 0, test_default_construct<TestSet>() );
     97   ConstCheck( 0, test_construct_iter_range<TestSet>( testSet2 ) );
     98   ConstCheck( testSet, test_copy_construct<TestSet>() );
     99   WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) );
    100 }
    101