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