os/ossrv/genericopenlibs/cppstdlib/stl/test/eh/test_valarray.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/eh/test_valarray.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +/*----------------------------------------------------------------------------------------------
     1.5 + * Portions Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     1.6 + *----------------------------------------------------------------------------------------------
     1.7 +*/
     1.8 +// Boris - this file is, um, rather incomplete. Please remove from distribution.
     1.9 +
    1.10 +/***********************************************************************************
    1.11 +  test_string.cpp
    1.12 +
    1.13 + * Copyright (c) 1997
    1.14 + * Mark of the Unicorn, Inc.
    1.15 + *
    1.16 + * Permission to use, copy, modify, distribute and sell this software
    1.17 + * and its documentation for any purpose is hereby granted without fee,
    1.18 + * provided that the above copyright notice appear in all copies and
    1.19 + * that both that copyright notice and this permission notice appear
    1.20 + * in supporting documentation.  Mark of the Unicorn makes no
    1.21 + * representations about the suitability of this software for any
    1.22 + * purpose.  It is provided "as is" without express or implied warranty.
    1.23 +
    1.24 +***********************************************************************************/
    1.25 +#include "Prefix.h"
    1.26 +#if defined( EH_VALARRAY_IMPLEMENTED )
    1.27 +#include "Tests.h"
    1.28 +#include <valarray>
    1.29 +#include "TestClass.h"
    1.30 +#include "LeakCheck.h"
    1.31 +#include "test_construct.h"
    1.32 +#include "test_assign_op.h"
    1.33 +#include "test_push_back.h"
    1.34 +#include "test_insert.h"
    1.35 +#include "test_push_front.h"
    1.36 +
    1.37 +typedef __valarray__<TestClass, eh_allocator(TestClass) > TestValarray;
    1.38 +
    1.39 +inline sequence_container_tag
    1.40 +container_category(const TestValarray&)
    1.41 +{
    1.42 +  return sequence_container_tag();
    1.43 +}
    1.44 +
    1.45 +void test_rope()
    1.46 +{
    1.47 +    TestValarray testValarray, testValarray2;
    1.48 +    size_t ropeSize = random_number(random_base);
    1.49 +
    1.50 +    while ( testValarray.size() < ropeSize )
    1.51 +    {
    1.52 +        TestValarray::value_type x = random_number(random_base) ;  // initialize before use
    1.53 +        testValarray.push_back( x );
    1.54 +        testValarray2.push_back( TestValarray::value_type() );
    1.55 +    }
    1.56 +    WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray) );
    1.57 +    WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, 0) );
    1.58 +    WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, testValarray.size()) );
    1.59 +
    1.60 +    WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base) ) );
    1.61 +    WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), 0 ) );
    1.62 +    WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), testValarray.size() ) );
    1.63 +
    1.64 +    size_t insCnt = random_number(random_base);
    1.65 +    TestValarray::value_type *insFirst = new TestValarray::value_type[1+insCnt];
    1.66 +
    1.67 +    WeakCheck( testValarray, insert_range_tester(testValarray, insFirst, insFirst+insCnt) );
    1.68 +    WeakCheck( testValarray, insert_range_at_begin_tester(testValarray, insFirst, insFirst+insCnt) );
    1.69 +    WeakCheck( testValarray, insert_range_at_end_tester(testValarray, insFirst, insFirst+insCnt) );
    1.70 +
    1.71 +    ConstCheck( 0, test_construct_pointer_range<TestValarray>(insFirst, insFirst+insCnt) );
    1.72 +    delete[] insFirst;
    1.73 +
    1.74 +    WeakCheck( testValarray, insert_range_tester(testValarray, testValarray2.begin(), testValarray2.end() ) );
    1.75 +
    1.76 +    WeakCheck( testValarray, test_push_front<TestValarray>(testValarray) );
    1.77 +    WeakCheck( testValarray, test_push_back<TestValarray>(testValarray) );
    1.78 +
    1.79 +    ConstCheck( 0, test_default_construct<TestValarray>() );
    1.80 +    ConstCheck( 0, test_construct_n<TestValarray>( random_number(random_base) ) );
    1.81 +    ConstCheck( 0, test_construct_n_instance<TestValarray>( random_number(random_base) ) );
    1.82 +    ConstCheck( 0, test_construct_iter_range<TestValarray>( testValarray2 ) );
    1.83 +    ConstCheck( testValarray, test_copy_construct<TestValarray>() );
    1.84 +
    1.85 +    WeakCheck( testValarray, test_assign_op<TestValarray>( testValarray2 ) );
    1.86 +}
    1.87 +
    1.88 +#endif // EH_ROPE_IMPLEMENTED