ReactOS 0.4.15-dev-8116-gf69e256
test_string.cpp
Go to the documentation of this file.
1/***********************************************************************************
2 test_string.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#include "Prefix.h"
17#if defined( EH_STRING_IMPLEMENTED )
18#include "Tests.h"
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"
26#include <string>
27
28USING_CSTD_NAME(size_t)
29
30typedef EH_STD::basic_string<char, EH_STD::char_traits<char>, eh_allocator(char) > TestString;
31
34{
36}
37
39 TestString testString, testString2;
40 size_t ropeSize = random_number(random_base);
41
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() );
46 }
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()) );
50
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() ) );
54
55 size_t insCnt = random_number(random_base);
56 TestString::value_type *insFirst = new TestString::value_type[1+insCnt];
57
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) );
61
62 ConstCheck( 0, test_construct_pointer_range<TestString>(insFirst, insFirst+insCnt) );
63 delete[] insFirst;
64
65 WeakCheck( testString, insert_range_tester(testString, testString2.begin(), testString2.end() ) );
66 /*
67 WeakCheck( testString, test_push_front<TestString>(testString) );
68 WeakCheck( testString, test_push_back<TestString>(testString) );
69 */
71 // requires _Reserve_t ConstCheck( 0, test_construct_n<TestString>( random_number(random_base) ) );
75
76 WeakCheck( testString, test_assign_op<TestString>( testString2 ) );
77}
78
79#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 USING_CSTD_NAME(name)
Definition: Prefix.h:310
#define eh_allocator(T)
Definition: Prefix.h:174
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned random_number(size_t range)
unsigned random_base
#define inline
Definition: compat.h:23
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
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
Definition: test_string.cpp:30
sequence_container_tag container_category(const TestString &)
Definition: test_string.cpp:33
void test_string()
Definition: test_string.cpp:38
#define const
Definition: zconf.h:233