sl@0: /*********************************************************************************** sl@0: test_string.cpp sl@0: sl@0: * Copyright (c) 1997 sl@0: * Mark of the Unicorn, Inc. sl@0: * sl@0: * Permission to use, copy, modify, distribute and sell this software sl@0: * and its documentation for any purpose is hereby granted without fee, sl@0: * provided that the above copyright notice appear in all copies and sl@0: * that both that copyright notice and this permission notice appear sl@0: * in supporting documentation. Mark of the Unicorn makes no sl@0: * representations about the suitability of this software for any sl@0: * purpose. It is provided "as is" without express or implied warranty. sl@0: sl@0: ***********************************************************************************/ sl@0: #include "Prefix.h" sl@0: #if defined( EH_STRING_IMPLEMENTED ) sl@0: #include "Tests.h" sl@0: #include "TestClass.h" sl@0: #include "LeakCheck.h" sl@0: #include "test_construct.h" sl@0: #include "test_assign_op.h" sl@0: #include "test_push_back.h" sl@0: #include "test_insert.h" sl@0: #include "test_push_front.h" sl@0: #include <string> sl@0: sl@0: USING_CSTD_NAME(size_t) sl@0: sl@0: typedef EH_STD::basic_string<char, EH_STD::char_traits<char>, eh_allocator(char) > TestString; sl@0: sl@0: inline sequence_container_tag sl@0: container_category(const TestString&) sl@0: { sl@0: return sequence_container_tag(); sl@0: } sl@0: sl@0: void test_string() { sl@0: TestString testString, testString2; sl@0: size_t ropeSize = random_number(random_base); sl@0: sl@0: while ( testString.size() < ropeSize ) { sl@0: TestString::value_type x = TestString::value_type(random_number(random_base)) ; // initialize before use sl@0: testString.append(1, x ); sl@0: testString2.append(1, TestString::value_type() ); sl@0: } sl@0: WeakCheck( testString, test_insert_one<TestString>(testString) ); sl@0: WeakCheck( testString, test_insert_one<TestString>(testString, 0) ); sl@0: WeakCheck( testString, test_insert_one<TestString>(testString, (int)testString.size()) ); sl@0: sl@0: WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base) ) ); sl@0: WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), 0 ) ); sl@0: WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), (int)testString.size() ) ); sl@0: sl@0: size_t insCnt = random_number(random_base); sl@0: TestString::value_type *insFirst = new TestString::value_type[1+insCnt]; sl@0: sl@0: WeakCheck( testString, insert_range_tester(testString, insFirst, insFirst+insCnt) ); sl@0: WeakCheck( testString, insert_range_at_begin_tester(testString, insFirst, insFirst+insCnt) ); sl@0: WeakCheck( testString, insert_range_at_end_tester(testString, insFirst, insFirst+insCnt) ); sl@0: sl@0: ConstCheck( 0, test_construct_pointer_range<TestString>(insFirst, insFirst+insCnt) ); sl@0: delete[] insFirst; sl@0: sl@0: WeakCheck( testString, insert_range_tester(testString, testString2.begin(), testString2.end() ) ); sl@0: /* sl@0: WeakCheck( testString, test_push_front<TestString>(testString) ); sl@0: WeakCheck( testString, test_push_back<TestString>(testString) ); sl@0: */ sl@0: ConstCheck( 0, test_default_construct<TestString>() ); sl@0: // requires _Reserve_t ConstCheck( 0, test_construct_n<TestString>( random_number(random_base) ) ); sl@0: ConstCheck( 0, test_construct_n_instance<TestString>( random_number(random_base) ) ); sl@0: ConstCheck( 0, test_construct_iter_range<TestString>( testString2 ) ); sl@0: ConstCheck( testString, test_copy_construct<TestString>() ); sl@0: sl@0: WeakCheck( testString, test_assign_op<TestString>( testString2 ) ); sl@0: } sl@0: sl@0: #endif // EH_ROPE_IMPLEMENTED