genericopenlibs/cppstdlib/stl/test/eh/test_valarray.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*----------------------------------------------------------------------------------------------
       
     2  * Portions Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3  *----------------------------------------------------------------------------------------------
       
     4 */
       
     5 // Boris - this file is, um, rather incomplete. Please remove from distribution.
       
     6 
       
     7 /***********************************************************************************
       
     8   test_string.cpp
       
     9 
       
    10  * Copyright (c) 1997
       
    11  * Mark of the Unicorn, Inc.
       
    12  *
       
    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.
       
    20 
       
    21 ***********************************************************************************/
       
    22 #include "Prefix.h"
       
    23 #if defined( EH_VALARRAY_IMPLEMENTED )
       
    24 #include "Tests.h"
       
    25 #include <valarray>
       
    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"
       
    33 
       
    34 typedef __valarray__<TestClass, eh_allocator(TestClass) > TestValarray;
       
    35 
       
    36 inline sequence_container_tag
       
    37 container_category(const TestValarray&)
       
    38 {
       
    39   return sequence_container_tag();
       
    40 }
       
    41 
       
    42 void test_rope()
       
    43 {
       
    44     TestValarray testValarray, testValarray2;
       
    45     size_t ropeSize = random_number(random_base);
       
    46 
       
    47     while ( testValarray.size() < ropeSize )
       
    48     {
       
    49         TestValarray::value_type x = random_number(random_base) ;  // initialize before use
       
    50         testValarray.push_back( x );
       
    51         testValarray2.push_back( TestValarray::value_type() );
       
    52     }
       
    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()) );
       
    56 
       
    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() ) );
       
    60 
       
    61     size_t insCnt = random_number(random_base);
       
    62     TestValarray::value_type *insFirst = new TestValarray::value_type[1+insCnt];
       
    63 
       
    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) );
       
    67 
       
    68     ConstCheck( 0, test_construct_pointer_range<TestValarray>(insFirst, insFirst+insCnt) );
       
    69     delete[] insFirst;
       
    70 
       
    71     WeakCheck( testValarray, insert_range_tester(testValarray, testValarray2.begin(), testValarray2.end() ) );
       
    72 
       
    73     WeakCheck( testValarray, test_push_front<TestValarray>(testValarray) );
       
    74     WeakCheck( testValarray, test_push_back<TestValarray>(testValarray) );
       
    75 
       
    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>() );
       
    81 
       
    82     WeakCheck( testValarray, test_assign_op<TestValarray>( testValarray2 ) );
       
    83 }
       
    84 
       
    85 #endif // EH_ROPE_IMPLEMENTED