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