sl@0
|
1 |
/***********************************************************************************
|
sl@0
|
2 |
test_string.cpp
|
sl@0
|
3 |
|
sl@0
|
4 |
* Copyright (c) 1997
|
sl@0
|
5 |
* Mark of the Unicorn, Inc.
|
sl@0
|
6 |
*
|
sl@0
|
7 |
* Permission to use, copy, modify, distribute and sell this software
|
sl@0
|
8 |
* and its documentation for any purpose is hereby granted without fee,
|
sl@0
|
9 |
* provided that the above copyright notice appear in all copies and
|
sl@0
|
10 |
* that both that copyright notice and this permission notice appear
|
sl@0
|
11 |
* in supporting documentation. Mark of the Unicorn makes no
|
sl@0
|
12 |
* representations about the suitability of this software for any
|
sl@0
|
13 |
* purpose. It is provided "as is" without express or implied warranty.
|
sl@0
|
14 |
|
sl@0
|
15 |
***********************************************************************************/
|
sl@0
|
16 |
#include "Prefix.h"
|
sl@0
|
17 |
#if defined( EH_STRING_IMPLEMENTED )
|
sl@0
|
18 |
#include "Tests.h"
|
sl@0
|
19 |
#include "TestClass.h"
|
sl@0
|
20 |
#include "LeakCheck.h"
|
sl@0
|
21 |
#include "test_construct.h"
|
sl@0
|
22 |
#include "test_assign_op.h"
|
sl@0
|
23 |
#include "test_push_back.h"
|
sl@0
|
24 |
#include "test_insert.h"
|
sl@0
|
25 |
#include "test_push_front.h"
|
sl@0
|
26 |
#include <string>
|
sl@0
|
27 |
|
sl@0
|
28 |
USING_CSTD_NAME(size_t)
|
sl@0
|
29 |
|
sl@0
|
30 |
typedef EH_STD::basic_string<char, EH_STD::char_traits<char>, eh_allocator(char) > TestString;
|
sl@0
|
31 |
|
sl@0
|
32 |
inline sequence_container_tag
|
sl@0
|
33 |
container_category(const TestString&)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
return sequence_container_tag();
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
void test_string() {
|
sl@0
|
39 |
TestString testString, testString2;
|
sl@0
|
40 |
size_t ropeSize = random_number(random_base);
|
sl@0
|
41 |
|
sl@0
|
42 |
while ( testString.size() < ropeSize ) {
|
sl@0
|
43 |
TestString::value_type x = TestString::value_type(random_number(random_base)) ; // initialize before use
|
sl@0
|
44 |
testString.append(1, x );
|
sl@0
|
45 |
testString2.append(1, TestString::value_type() );
|
sl@0
|
46 |
}
|
sl@0
|
47 |
WeakCheck( testString, test_insert_one<TestString>(testString) );
|
sl@0
|
48 |
WeakCheck( testString, test_insert_one<TestString>(testString, 0) );
|
sl@0
|
49 |
WeakCheck( testString, test_insert_one<TestString>(testString, (int)testString.size()) );
|
sl@0
|
50 |
|
sl@0
|
51 |
WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base) ) );
|
sl@0
|
52 |
WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), 0 ) );
|
sl@0
|
53 |
WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), (int)testString.size() ) );
|
sl@0
|
54 |
|
sl@0
|
55 |
size_t insCnt = random_number(random_base);
|
sl@0
|
56 |
TestString::value_type *insFirst = new TestString::value_type[1+insCnt];
|
sl@0
|
57 |
|
sl@0
|
58 |
WeakCheck( testString, insert_range_tester(testString, insFirst, insFirst+insCnt) );
|
sl@0
|
59 |
WeakCheck( testString, insert_range_at_begin_tester(testString, insFirst, insFirst+insCnt) );
|
sl@0
|
60 |
WeakCheck( testString, insert_range_at_end_tester(testString, insFirst, insFirst+insCnt) );
|
sl@0
|
61 |
|
sl@0
|
62 |
ConstCheck( 0, test_construct_pointer_range<TestString>(insFirst, insFirst+insCnt) );
|
sl@0
|
63 |
delete[] insFirst;
|
sl@0
|
64 |
|
sl@0
|
65 |
WeakCheck( testString, insert_range_tester(testString, testString2.begin(), testString2.end() ) );
|
sl@0
|
66 |
/*
|
sl@0
|
67 |
WeakCheck( testString, test_push_front<TestString>(testString) );
|
sl@0
|
68 |
WeakCheck( testString, test_push_back<TestString>(testString) );
|
sl@0
|
69 |
*/
|
sl@0
|
70 |
ConstCheck( 0, test_default_construct<TestString>() );
|
sl@0
|
71 |
// requires _Reserve_t ConstCheck( 0, test_construct_n<TestString>( random_number(random_base) ) );
|
sl@0
|
72 |
ConstCheck( 0, test_construct_n_instance<TestString>( random_number(random_base) ) );
|
sl@0
|
73 |
ConstCheck( 0, test_construct_iter_range<TestString>( testString2 ) );
|
sl@0
|
74 |
ConstCheck( testString, test_copy_construct<TestString>() );
|
sl@0
|
75 |
|
sl@0
|
76 |
WeakCheck( testString, test_assign_op<TestString>( testString2 ) );
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
#endif // EH_ROPE_IMPLEMENTED
|