Home | History | Annotate | Download | only in eh
      1 // Boris - this file is, um, rather incomplete. Please remove from distribution.
      2 
      3 /***********************************************************************************
      4   test_string.cpp
      5 
      6  * Copyright (c) 1997
      7  * Mark of the Unicorn, Inc.
      8  *
      9  * Permission to use, copy, modify, distribute and sell this software
     10  * and its documentation for any purpose is hereby granted without fee,
     11  * provided that the above copyright notice appear in all copies and
     12  * that both that copyright notice and this permission notice appear
     13  * in supporting documentation.  Mark of the Unicorn makes no
     14  * representations about the suitability of this software for any
     15  * purpose.  It is provided "as is" without express or implied warranty.
     16 
     17 ***********************************************************************************/
     18 #include "Prefix.h"
     19 #if defined( EH_VALARRAY_IMPLEMENTED )
     20 #include "Tests.h"
     21 #include <valarray>
     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 
     30 typedef __valarray__<TestClass, eh_allocator(TestClass) > TestValarray;
     31 
     32 inline sequence_container_tag
     33 container_category(const TestValarray&)
     34 {
     35   return sequence_container_tag();
     36 }
     37 
     38 void test_rope()
     39 {
     40     TestValarray testValarray, testValarray2;
     41     size_t ropeSize = random_number(random_base);
     42 
     43     while ( testValarray.size() < ropeSize )
     44     {
     45         TestValarray::value_type x = random_number(random_base) ;  // initialize before use
     46         testValarray.push_back( x );
     47         testValarray2.push_back( TestValarray::value_type() );
     48     }
     49     WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray) );
     50     WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, 0) );
     51     WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, testValarray.size()) );
     52 
     53     WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base) ) );
     54     WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), 0 ) );
     55     WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), testValarray.size() ) );
     56 
     57     size_t insCnt = random_number(random_base);
     58     TestValarray::value_type *insFirst = new TestValarray::value_type[1+insCnt];
     59 
     60     WeakCheck( testValarray, insert_range_tester(testValarray, insFirst, insFirst+insCnt) );
     61     WeakCheck( testValarray, insert_range_at_begin_tester(testValarray, insFirst, insFirst+insCnt) );
     62     WeakCheck( testValarray, insert_range_at_end_tester(testValarray, insFirst, insFirst+insCnt) );
     63 
     64     ConstCheck( 0, test_construct_pointer_range<TestValarray>(insFirst, insFirst+insCnt) );
     65     delete[] insFirst;
     66 
     67     WeakCheck( testValarray, insert_range_tester(testValarray, testValarray2.begin(), testValarray2.end() ) );
     68 
     69     WeakCheck( testValarray, test_push_front<TestValarray>(testValarray) );
     70     WeakCheck( testValarray, test_push_back<TestValarray>(testValarray) );
     71 
     72     ConstCheck( 0, test_default_construct<TestValarray>() );
     73     ConstCheck( 0, test_construct_n<TestValarray>( random_number(random_base) ) );
     74     ConstCheck( 0, test_construct_n_instance<TestValarray>( random_number(random_base) ) );
     75     ConstCheck( 0, test_construct_iter_range<TestValarray>( testValarray2 ) );
     76     ConstCheck( testValarray, test_copy_construct<TestValarray>() );
     77 
     78     WeakCheck( testValarray, test_assign_op<TestValarray>( testValarray2 ) );
     79 }
     80 
     81 #endif // EH_ROPE_IMPLEMENTED
     82