1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/eh/test_rope.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,117 @@
1.4 +/***********************************************************************************
1.5 + test_rope.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 +# ifdef __SUNPRO_CC
1.21 +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1
1.22 +# endif
1.23 +
1.24 +#include "Prefix.h"
1.25 +#include "Tests.h"
1.26 +#include "TestClass.h"
1.27 +#include "LeakCheck.h"
1.28 +#include "test_construct.h"
1.29 +#include "test_assign_op.h"
1.30 +#include "test_push_back.h"
1.31 +#include "test_insert.h"
1.32 +#include "test_push_front.h"
1.33 +
1.34 +#if defined( EH_ROPE_IMPLEMENTED )
1.35 +#if !( defined(__MWERKS__) && __MWERKS__ < 0x1900 ) // CW1.8 can't compile this!
1.36 +# define __STD_STUFF 1
1.37 +# if defined (EH_NEW_HEADERS)
1.38 +#include <rope>
1.39 +#else
1.40 +#include <rope.h>
1.41 +#endif
1.42 +
1.43 +
1.44 +typedef STLPORT::rope<char, eh_allocator(char) > TestRope;
1.45 +
1.46 +# if ( _STLP_STATIC_TEMPLATE_DATA < 1 )
1.47 +
1.48 +// Instantiate TestRope static data members
1.49 +const unsigned long TestRope::_S_min_len[46] = { \
1.50 +/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21, \
1.51 +/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377, \
1.52 +/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181, \
1.53 +/* 18 */6765ul, /* 19 */10946ul, /* 20 */17711ul, /* 21 */28657ul, /* 22 */46368ul, \
1.54 +/* 23 */75025ul, /* 24 */121393ul, /* 25 */196418ul, /* 26 */317811ul, \
1.55 +/* 27 */514229ul, /* 28 */832040ul, /* 29 */1346269ul, /* 30 */2178309ul, \
1.56 +/* 31 */3524578ul, /* 32 */5702887ul, /* 33 */9227465ul, /* 34 */14930352ul, \
1.57 +/* 35 */24157817ul, /* 36 */39088169ul, /* 37 */63245986ul, /* 38 */102334155ul, \
1.58 +/* 39 */165580141ul, /* 40 */267914296ul, /* 41 */433494437ul, \
1.59 +/* 42 */701408733ul, /* 43 */1134903170ul, /* 44 */1836311903ul, \
1.60 +/* 45 */2971215073ul };
1.61 +
1.62 +# endif /* ( _STLP_STATIC_TEMPLATE_DATA < 1 ) */
1.63 +
1.64 +inline sequence_container_tag
1.65 +container_category(const TestRope&)
1.66 +{
1.67 + return sequence_container_tag();
1.68 +}
1.69 +
1.70 +void test_rope()
1.71 +{
1.72 + TestRope testRope, testRope2;
1.73 + size_t ropeSize = random_number(random_base);
1.74 +
1.75 + while ( testRope.size() < ropeSize )
1.76 + {
1.77 + TestRope::value_type x = TestRope::value_type(random_number(random_base)); // initialize before use
1.78 + testRope.push_back( x );
1.79 + testRope2.push_back( TestRope::value_type() );
1.80 + }
1.81 + WeakCheck( testRope, test_insert_one<TestRope>(testRope) );
1.82 + WeakCheck( testRope, test_insert_one<TestRope>(testRope, 0) );
1.83 + WeakCheck( testRope, test_insert_one<TestRope>(testRope, (int)testRope.size()) );
1.84 +
1.85 + WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base) ) );
1.86 + WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), 0 ) );
1.87 + WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), (int)testRope.size() ) );
1.88 +
1.89 + size_t insCnt = random_number(random_base);
1.90 + TestRope::value_type *insFirst = new TestRope::value_type[1+insCnt];
1.91 +
1.92 + WeakCheck( testRope, insert_range_tester(testRope, insFirst, insFirst+insCnt) );
1.93 + WeakCheck( testRope, insert_range_at_begin_tester(testRope, insFirst, insFirst+insCnt) );
1.94 + WeakCheck( testRope, insert_range_at_end_tester(testRope, insFirst, insFirst+insCnt) );
1.95 +
1.96 + ConstCheck( 0, test_construct_pointer_range<TestRope>(insFirst, insFirst+insCnt) );
1.97 + delete[] insFirst;
1.98 +
1.99 + WeakCheck( testRope, insert_range_tester(testRope, testRope2.begin(), testRope2.end() ) );
1.100 +
1.101 + WeakCheck( testRope, test_push_front<TestRope>(testRope) );
1.102 + WeakCheck( testRope, test_push_back<TestRope>(testRope) );
1.103 +
1.104 + ConstCheck( 0, test_default_construct<TestRope>() );
1.105 +
1.106 +// dwa 1/25/00 - not actually valid for rope, because it doesn't
1.107 +// have the constructor in question! The code will compile, but with the
1.108 +// wrong result (the constructor that gets used does something different).
1.109 +
1.110 +// ConstCheck( 0, test_construct_n<TestRope>( random_number(random_base) ) );
1.111 +
1.112 + ConstCheck( 0, test_construct_n_instance<TestRope>( random_number(random_base) ) );
1.113 + ConstCheck( 0, test_construct_iter_range<TestRope>( testRope2 ) );
1.114 + ConstCheck( testRope, test_copy_construct<TestRope>() );
1.115 +
1.116 + WeakCheck( testRope, test_assign_op<TestRope>( testRope2 ) );
1.117 +}
1.118 +#endif // __MWERKS__
1.119 +
1.120 +#endif // EH_ROPE_IMPLEMENTED