sl@0
|
1 |
/***********************************************************************************
|
sl@0
|
2 |
test_rope.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 |
|
sl@0
|
17 |
# ifdef __SUNPRO_CC
|
sl@0
|
18 |
# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1
|
sl@0
|
19 |
# endif
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "Prefix.h"
|
sl@0
|
22 |
#include "Tests.h"
|
sl@0
|
23 |
#include "TestClass.h"
|
sl@0
|
24 |
#include "LeakCheck.h"
|
sl@0
|
25 |
#include "test_construct.h"
|
sl@0
|
26 |
#include "test_assign_op.h"
|
sl@0
|
27 |
#include "test_push_back.h"
|
sl@0
|
28 |
#include "test_insert.h"
|
sl@0
|
29 |
#include "test_push_front.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
#if defined( EH_ROPE_IMPLEMENTED )
|
sl@0
|
32 |
#if !( defined(__MWERKS__) && __MWERKS__ < 0x1900 ) // CW1.8 can't compile this!
|
sl@0
|
33 |
# define __STD_STUFF 1
|
sl@0
|
34 |
# if defined (EH_NEW_HEADERS)
|
sl@0
|
35 |
#include <rope>
|
sl@0
|
36 |
#else
|
sl@0
|
37 |
#include <rope.h>
|
sl@0
|
38 |
#endif
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
typedef STLPORT::rope<char, eh_allocator(char) > TestRope;
|
sl@0
|
42 |
|
sl@0
|
43 |
# if ( _STLP_STATIC_TEMPLATE_DATA < 1 )
|
sl@0
|
44 |
|
sl@0
|
45 |
// Instantiate TestRope static data members
|
sl@0
|
46 |
const unsigned long TestRope::_S_min_len[46] = { \
|
sl@0
|
47 |
/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21, \
|
sl@0
|
48 |
/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377, \
|
sl@0
|
49 |
/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181, \
|
sl@0
|
50 |
/* 18 */6765ul, /* 19 */10946ul, /* 20 */17711ul, /* 21 */28657ul, /* 22 */46368ul, \
|
sl@0
|
51 |
/* 23 */75025ul, /* 24 */121393ul, /* 25 */196418ul, /* 26 */317811ul, \
|
sl@0
|
52 |
/* 27 */514229ul, /* 28 */832040ul, /* 29 */1346269ul, /* 30 */2178309ul, \
|
sl@0
|
53 |
/* 31 */3524578ul, /* 32 */5702887ul, /* 33 */9227465ul, /* 34 */14930352ul, \
|
sl@0
|
54 |
/* 35 */24157817ul, /* 36 */39088169ul, /* 37 */63245986ul, /* 38 */102334155ul, \
|
sl@0
|
55 |
/* 39 */165580141ul, /* 40 */267914296ul, /* 41 */433494437ul, \
|
sl@0
|
56 |
/* 42 */701408733ul, /* 43 */1134903170ul, /* 44 */1836311903ul, \
|
sl@0
|
57 |
/* 45 */2971215073ul };
|
sl@0
|
58 |
|
sl@0
|
59 |
# endif /* ( _STLP_STATIC_TEMPLATE_DATA < 1 ) */
|
sl@0
|
60 |
|
sl@0
|
61 |
inline sequence_container_tag
|
sl@0
|
62 |
container_category(const TestRope&)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
return sequence_container_tag();
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
void test_rope()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
TestRope testRope, testRope2;
|
sl@0
|
70 |
size_t ropeSize = random_number(random_base);
|
sl@0
|
71 |
|
sl@0
|
72 |
while ( testRope.size() < ropeSize )
|
sl@0
|
73 |
{
|
sl@0
|
74 |
TestRope::value_type x = TestRope::value_type(random_number(random_base)); // initialize before use
|
sl@0
|
75 |
testRope.push_back( x );
|
sl@0
|
76 |
testRope2.push_back( TestRope::value_type() );
|
sl@0
|
77 |
}
|
sl@0
|
78 |
WeakCheck( testRope, test_insert_one<TestRope>(testRope) );
|
sl@0
|
79 |
WeakCheck( testRope, test_insert_one<TestRope>(testRope, 0) );
|
sl@0
|
80 |
WeakCheck( testRope, test_insert_one<TestRope>(testRope, (int)testRope.size()) );
|
sl@0
|
81 |
|
sl@0
|
82 |
WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base) ) );
|
sl@0
|
83 |
WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), 0 ) );
|
sl@0
|
84 |
WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), (int)testRope.size() ) );
|
sl@0
|
85 |
|
sl@0
|
86 |
size_t insCnt = random_number(random_base);
|
sl@0
|
87 |
TestRope::value_type *insFirst = new TestRope::value_type[1+insCnt];
|
sl@0
|
88 |
|
sl@0
|
89 |
WeakCheck( testRope, insert_range_tester(testRope, insFirst, insFirst+insCnt) );
|
sl@0
|
90 |
WeakCheck( testRope, insert_range_at_begin_tester(testRope, insFirst, insFirst+insCnt) );
|
sl@0
|
91 |
WeakCheck( testRope, insert_range_at_end_tester(testRope, insFirst, insFirst+insCnt) );
|
sl@0
|
92 |
|
sl@0
|
93 |
ConstCheck( 0, test_construct_pointer_range<TestRope>(insFirst, insFirst+insCnt) );
|
sl@0
|
94 |
delete[] insFirst;
|
sl@0
|
95 |
|
sl@0
|
96 |
WeakCheck( testRope, insert_range_tester(testRope, testRope2.begin(), testRope2.end() ) );
|
sl@0
|
97 |
|
sl@0
|
98 |
WeakCheck( testRope, test_push_front<TestRope>(testRope) );
|
sl@0
|
99 |
WeakCheck( testRope, test_push_back<TestRope>(testRope) );
|
sl@0
|
100 |
|
sl@0
|
101 |
ConstCheck( 0, test_default_construct<TestRope>() );
|
sl@0
|
102 |
|
sl@0
|
103 |
// dwa 1/25/00 - not actually valid for rope, because it doesn't
|
sl@0
|
104 |
// have the constructor in question! The code will compile, but with the
|
sl@0
|
105 |
// wrong result (the constructor that gets used does something different).
|
sl@0
|
106 |
|
sl@0
|
107 |
// ConstCheck( 0, test_construct_n<TestRope>( random_number(random_base) ) );
|
sl@0
|
108 |
|
sl@0
|
109 |
ConstCheck( 0, test_construct_n_instance<TestRope>( random_number(random_base) ) );
|
sl@0
|
110 |
ConstCheck( 0, test_construct_iter_range<TestRope>( testRope2 ) );
|
sl@0
|
111 |
ConstCheck( testRope, test_copy_construct<TestRope>() );
|
sl@0
|
112 |
|
sl@0
|
113 |
WeakCheck( testRope, test_assign_op<TestRope>( testRope2 ) );
|
sl@0
|
114 |
}
|
sl@0
|
115 |
#endif // __MWERKS__
|
sl@0
|
116 |
|
sl@0
|
117 |
#endif // EH_ROPE_IMPLEMENTED
|