ReactOS 0.4.15-dev-7942-gd23573b
test_valarray.cpp
Go to the documentation of this file.
1// Boris - this file is, um, rather incomplete. Please remove from distribution.
2
3/***********************************************************************************
4 test_string.cpp
5
6 * Copyright (c) 1997
7 * Mark of the Unicorn, Inc.
8 *
9 * Permission to use, copy, modify, distribute and sell this software
10 * and its documentation for any purpose is hereby granted without fee,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation. Mark of the Unicorn makes no
14 * representations about the suitability of this software for any
15 * purpose. It is provided "as is" without express or implied warranty.
16
17***********************************************************************************/
18#include "Prefix.h"
19#if defined( EH_VALARRAY_IMPLEMENTED )
20#include "Tests.h"
21#include <valarray>
22#include "TestClass.h"
23#include "LeakCheck.h"
24#include "test_construct.h"
25#include "test_assign_op.h"
26#include "test_push_back.h"
27#include "test_insert.h"
28#include "test_push_front.h"
29
30typedef __valarray__<TestClass, eh_allocator(TestClass) > TestValarray;
31
33container_category(const TestValarray&)
34{
36}
37
38void test_rope()
39{
40 TestValarray testValarray, testValarray2;
41 size_t ropeSize = random_number(random_base);
42
43 while ( testValarray.size() < ropeSize )
44 {
45 TestValarray::value_type x = random_number(random_base) ; // initialize before use
46 testValarray.push_back( x );
47 testValarray2.push_back( TestValarray::value_type() );
48 }
49 WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray) );
50 WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, 0) );
51 WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, testValarray.size()) );
52
53 WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base) ) );
54 WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), 0 ) );
55 WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), testValarray.size() ) );
56
57 size_t insCnt = random_number(random_base);
58 TestValarray::value_type *insFirst = new TestValarray::value_type[1+insCnt];
59
60 WeakCheck( testValarray, insert_range_tester(testValarray, insFirst, insFirst+insCnt) );
61 WeakCheck( testValarray, insert_range_at_begin_tester(testValarray, insFirst, insFirst+insCnt) );
62 WeakCheck( testValarray, insert_range_at_end_tester(testValarray, insFirst, insFirst+insCnt) );
63
64 ConstCheck( 0, test_construct_pointer_range<TestValarray>(insFirst, insFirst+insCnt) );
65 delete[] insFirst;
66
67 WeakCheck( testValarray, insert_range_tester(testValarray, testValarray2.begin(), testValarray2.end() ) );
68
69 WeakCheck( testValarray, test_push_front<TestValarray>(testValarray) );
70 WeakCheck( testValarray, test_push_back<TestValarray>(testValarray) );
71
77
78 WeakCheck( testValarray, test_assign_op<TestValarray>( testValarray2 ) );
79}
80
81#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
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned random_number(size_t range)
unsigned random_base
sequence_container_tag container_category(const BitVector &)
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
void test_rope()
Definition: test_rope.cpp:49