First public contribution.
1 /***********************************************************************************
5 * Mark of the Unicorn, Inc.
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.
15 ***********************************************************************************/
17 #if defined( EH_STRING_IMPLEMENTED )
19 #include "TestClass.h"
20 #include "LeakCheck.h"
21 #include "test_construct.h"
22 #include "test_assign_op.h"
23 #include "test_push_back.h"
24 #include "test_insert.h"
25 #include "test_push_front.h"
28 USING_CSTD_NAME(size_t)
30 typedef EH_STD::basic_string<char, EH_STD::char_traits<char>, eh_allocator(char) > TestString;
32 inline sequence_container_tag
33 container_category(const TestString&)
35 return sequence_container_tag();
39 TestString testString, testString2;
40 size_t ropeSize = random_number(random_base);
42 while ( testString.size() < ropeSize ) {
43 TestString::value_type x = TestString::value_type(random_number(random_base)) ; // initialize before use
44 testString.append(1, x );
45 testString2.append(1, TestString::value_type() );
47 WeakCheck( testString, test_insert_one<TestString>(testString) );
48 WeakCheck( testString, test_insert_one<TestString>(testString, 0) );
49 WeakCheck( testString, test_insert_one<TestString>(testString, (int)testString.size()) );
51 WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base) ) );
52 WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), 0 ) );
53 WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), (int)testString.size() ) );
55 size_t insCnt = random_number(random_base);
56 TestString::value_type *insFirst = new TestString::value_type[1+insCnt];
58 WeakCheck( testString, insert_range_tester(testString, insFirst, insFirst+insCnt) );
59 WeakCheck( testString, insert_range_at_begin_tester(testString, insFirst, insFirst+insCnt) );
60 WeakCheck( testString, insert_range_at_end_tester(testString, insFirst, insFirst+insCnt) );
62 ConstCheck( 0, test_construct_pointer_range<TestString>(insFirst, insFirst+insCnt) );
65 WeakCheck( testString, insert_range_tester(testString, testString2.begin(), testString2.end() ) );
67 WeakCheck( testString, test_push_front<TestString>(testString) );
68 WeakCheck( testString, test_push_back<TestString>(testString) );
70 ConstCheck( 0, test_default_construct<TestString>() );
71 // requires _Reserve_t ConstCheck( 0, test_construct_n<TestString>( random_number(random_base) ) );
72 ConstCheck( 0, test_construct_n_instance<TestString>( random_number(random_base) ) );
73 ConstCheck( 0, test_construct_iter_range<TestString>( testString2 ) );
74 ConstCheck( testString, test_copy_construct<TestString>() );
76 WeakCheck( testString, test_assign_op<TestString>( testString2 ) );
79 #endif // EH_ROPE_IMPLEMENTED