1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/eh/test_deque.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,99 @@
1.4 +/***********************************************************************************
1.5 + test_deque.cpp
1.6 +
1.7 + * Copyright (c) 1997
1.8 + * Mark of the Unicorn, Inc.
1.9 + *
1.10 + * Permission to use, copy, modify, distribute and sell this software
1.11 + * and its documentation for any purpose is hereby granted without fee,
1.12 + * provided that the above copyright notice appear in all copies and
1.13 + * that both that copyright notice and this permission notice appear
1.14 + * in supporting documentation. Mark of the Unicorn makes no
1.15 + * representations about the suitability of this software for any
1.16 + * purpose. It is provided "as is" without express or implied warranty.
1.17 +
1.18 +***********************************************************************************/
1.19 +
1.20 +#include "Tests.h"
1.21 +# if defined (EH_NEW_HEADERS)
1.22 +# ifdef __SUNPRO_CC
1.23 +# include <stdio.h>
1.24 +# else
1.25 +# include <cstdio>
1.26 +# endif
1.27 +# include <deque>
1.28 +# else
1.29 +# include <stdio.h>
1.30 +# include <deque.h>
1.31 +# endif
1.32 +#include "TestClass.h"
1.33 +#include "LeakCheck.h"
1.34 +#include "test_construct.h"
1.35 +#include "test_assign_op.h"
1.36 +#include "test_push_back.h"
1.37 +#include "test_insert.h"
1.38 +#include "test_push_front.h"
1.39 +
1.40 +typedef TestClass DQTestClass;
1.41 +
1.42 +typedef EH_STD::deque<DQTestClass, eh_allocator(DQTestClass) > TestDeque;
1.43 +
1.44 +inline sequence_container_tag
1.45 +container_category(const TestDeque&)
1.46 +{
1.47 + return sequence_container_tag();
1.48 +}
1.49 +
1.50 +void test_deque()
1.51 +{
1.52 + size_t dequeSize = random_number(random_base);
1.53 + TestDeque emptyDeque;
1.54 + TestDeque testDeque, testDeque2;
1.55 + while ( testDeque.size() < dequeSize )
1.56 + {
1.57 + DQTestClass x;
1.58 + testDeque.push_back( x );
1.59 + testDeque2.push_back( DQTestClass() );
1.60 + }
1.61 +
1.62 + ConstCheck( testDeque, test_copy_construct<TestDeque>() );
1.63 + WeakCheck( testDeque, test_insert_one<TestDeque>(testDeque) );
1.64 + StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque,0) );
1.65 + StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque, testDeque.size()) );
1.66 +
1.67 + WeakCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base) ) );
1.68 + StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), 0 ) );
1.69 + StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), testDeque.size() ) );
1.70 +
1.71 + size_t insCnt = random_number(random_base);
1.72 + DQTestClass *insFirst = new TestDeque::value_type[insCnt+1];
1.73 +
1.74 + WeakCheck( testDeque, insert_range_tester(testDeque, (DQTestClass *)insFirst,
1.75 + insFirst+insCnt) );
1.76 + StrongCheck( testDeque, insert_range_at_begin_tester(testDeque, (DQTestClass *)insFirst,
1.77 + insFirst+insCnt) );
1.78 + StrongCheck( testDeque, insert_range_at_end_tester(testDeque, (DQTestClass *)insFirst,
1.79 + insFirst+insCnt) );
1.80 +
1.81 + ConstCheck( 0, test_construct_pointer_range<TestDeque>( (DQTestClass *)insFirst,
1.82 + insFirst+insCnt ) );
1.83 + delete[] insFirst;
1.84 +
1.85 + WeakCheck( testDeque, insert_range_tester(testDeque, testDeque2.begin(), testDeque2.end() ) );
1.86 +
1.87 + StrongCheck( testDeque, test_push_back<TestDeque>(testDeque) );
1.88 + StrongCheck( emptyDeque, test_push_back<TestDeque>(emptyDeque) );
1.89 + StrongCheck( testDeque, test_push_front<TestDeque>(testDeque) );
1.90 + StrongCheck( emptyDeque, test_push_front<TestDeque>(emptyDeque) );
1.91 +
1.92 +
1.93 + ConstCheck( 0, test_default_construct<TestDeque>() );
1.94 + ConstCheck( 0, test_construct_n<TestDeque>( random_number(random_base) ) );
1.95 + ConstCheck( 0, test_construct_n_instance<TestDeque>( random_number(random_base) ) );
1.96 + ConstCheck( 0, test_construct_iter_range<TestDeque>( testDeque2 ) );
1.97 +
1.98 + testDeque2.resize( testDeque.size() * 3 / 2 );
1.99 + WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) );
1.100 + testDeque2.resize( testDeque.size() * 2 / 3 );
1.101 + WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) );
1.102 +}