Home | History | Annotate | Download | only in eh
      1 /***********************************************************************************
      2   test_rope.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 
     17 # ifdef __SUNPRO_CC
     18 #  define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1
     19 # endif
     20 
     21 #include "Prefix.h"
     22 #include "Tests.h"
     23 #include "TestClass.h"
     24 #include "LeakCheck.h"
     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 
     31 #if defined( EH_ROPE_IMPLEMENTED )
     32 #if !( defined(__MWERKS__) && __MWERKS__ < 0x1900 )    // CW1.8 can't compile this!
     33 # define __STD_STUFF 1
     34 # if defined (EH_NEW_HEADERS)
     35 #include <rope>
     36 #else
     37 #include <rope.h>
     38 #endif
     39 
     40 
     41 typedef STLPORT::rope<char, eh_allocator(char) > TestRope;
     42 
     43 inline sequence_container_tag
     44 container_category(const TestRope&)
     45 {
     46   return sequence_container_tag();
     47 }
     48 
     49 void test_rope()
     50 {
     51     TestRope testRope, testRope2;
     52     size_t ropeSize = random_number(random_base);
     53 
     54     while ( testRope.size() < ropeSize )
     55     {
     56         TestRope::value_type x = TestRope::value_type(random_number(random_base));  // initialize before use
     57         testRope.push_back( x );
     58         testRope2.push_back( TestRope::value_type() );
     59     }
     60     WeakCheck( testRope, test_insert_one<TestRope>(testRope) );
     61     WeakCheck( testRope, test_insert_one<TestRope>(testRope, 0) );
     62     WeakCheck( testRope, test_insert_one<TestRope>(testRope, (int)testRope.size()) );
     63 
     64     WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base) ) );
     65     WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), 0 ) );
     66     WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), (int)testRope.size() ) );
     67 
     68     size_t insCnt = random_number(random_base);
     69     TestRope::value_type *insFirst = new TestRope::value_type[1+insCnt];
     70 
     71     WeakCheck( testRope, insert_range_tester(testRope, insFirst, insFirst+insCnt) );
     72     WeakCheck( testRope, insert_range_at_begin_tester(testRope, insFirst, insFirst+insCnt) );
     73     WeakCheck( testRope, insert_range_at_end_tester(testRope, insFirst, insFirst+insCnt) );
     74 
     75     ConstCheck( 0, test_construct_pointer_range<TestRope>(insFirst, insFirst+insCnt) );
     76     delete[] insFirst;
     77 
     78     WeakCheck( testRope, insert_range_tester(testRope, testRope2.begin(), testRope2.end() ) );
     79 
     80     WeakCheck( testRope, test_push_front<TestRope>(testRope) );
     81     WeakCheck( testRope, test_push_back<TestRope>(testRope) );
     82 
     83     ConstCheck( 0, test_default_construct<TestRope>() );
     84 
     85 // dwa 1/25/00 - not actually valid for rope, because it doesn't
     86 // have the constructor in question! The code will compile, but with the
     87 // wrong result (the constructor that gets used does something different).
     88 
     89 //  ConstCheck( 0, test_construct_n<TestRope>( random_number(random_base) ) );
     90 
     91     ConstCheck( 0, test_construct_n_instance<TestRope>( random_number(random_base) ) );
     92     ConstCheck( 0, test_construct_iter_range<TestRope>( testRope2 ) );
     93     ConstCheck( testRope, test_copy_construct<TestRope>() );
     94 
     95     WeakCheck( testRope, test_assign_op<TestRope>( testRope2 ) );
     96 }
     97 #endif // __MWERKS__
     98 
     99 #endif // EH_ROPE_IMPLEMENTED
    100