ReactOS 0.4.15-dev-7907-g95bf896
test_rope.cpp
Go to the documentation of this file.
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
41typedef STLPORT::rope<char, eh_allocator(char) > TestRope;
42
45{
47}
48
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
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
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
94
95 WeakCheck( testRope, test_assign_op<TestRope>( testRope2 ) );
96}
97#endif // __MWERKS__
98
99#endif // EH_ROPE_IMPLEMENTED
void ConstCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:103
void WeakCheck(const Value &v, const Operation &op, long max_iters=2000000)
Definition: LeakCheck.h:65
#define eh_allocator(T)
Definition: Prefix.h:174
unsigned char
Definition: typeof.h:29
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned random_number(size_t range)
unsigned random_base
test_insert_range< C, Iter > insert_range_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:535
test_insert_range< C, Iter > insert_range_at_begin_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:541
test_insert_range< C, Iter > insert_range_at_end_tester(const C &orig, const Iter &first, const Iter &last)
Definition: test_insert.h:547
sequence_container_tag container_category(const TestRope &)
Definition: test_rope.cpp:44
void test_rope()
Definition: test_rope.cpp:49
STLPORT::rope< char, eh_allocator(char) > TestRope
Definition: test_rope.cpp:41