home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / eh / test_string.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  3KB  |  83 lines

  1. /***********************************************************************************
  2.     test_string.cpp
  3.     
  4.  * Copyright (c) 1997
  5.  * Mark of the Unicorn, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute and sell this software
  8.  * and its documentation for any purpose is hereby granted without fee,
  9.  * provided that the above copyright notice appear in all copies and
  10.  * that both that copyright notice and this permission notice appear
  11.  * in supporting documentation.  Mark of the Unicorn makes no
  12.  * representations about the suitability of this software for any
  13.  * purpose.  It is provided "as is" without express or implied warranty.
  14.  
  15. ***********************************************************************************/
  16. #include "Prefix.h"
  17. #if defined( EH_STRING_IMPLEMENTED )
  18. #include "Tests.h"
  19. #include "TestClass.h"
  20. #include "LeakCheck.h"
  21. #include "test_construct.h"
  22. #include "test_assign_op.h"
  23. #include "test_push_back.h"
  24. #include "test_insert.h"
  25. #include "test_push_front.h"
  26. #include <string>
  27.  
  28. USING_CSTD_NAME(size_t)
  29.   
  30. typedef EH_STD::basic_string<char, EH_STD::char_traits<char>, eh_allocator(char) > TestString;
  31.  
  32. inline sequence_container_tag
  33. container_category(const TestString&)
  34. {
  35.   return sequence_container_tag();
  36. }
  37.  
  38. void test_string()
  39. {
  40.     TestString testString, testString2;
  41.     EH_STD::size_t ropeSize = random_number(random_base);
  42.     
  43.     while ( testString.size() < ropeSize )
  44.     {
  45.         TestString::value_type x = TestString::value_type(random_number(random_base)) ;    // initialize before use
  46.         testString.append(1, x );
  47.         testString2.append(1, TestString::value_type() );
  48.     }
  49.     WeakCheck( testString, test_insert_one<TestString>(testString) );
  50.     WeakCheck( testString, test_insert_one<TestString>(testString, 0) );
  51.     WeakCheck( testString, test_insert_one<TestString>(testString, (int)testString.size()) );
  52.  
  53.     WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base) ) );
  54.     WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), 0 ) );
  55.     WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), (int)testString.size() ) );
  56.     
  57.     EH_STD::size_t insCnt = random_number(random_base);
  58.     TestString::value_type *insFirst = new TestString::value_type[1+insCnt];
  59.  
  60.     WeakCheck( testString, insert_range_tester(testString, insFirst, insFirst+insCnt) );
  61.     WeakCheck( testString, insert_range_at_begin_tester(testString, insFirst, insFirst+insCnt) );
  62.     WeakCheck( testString, insert_range_at_end_tester(testString, insFirst, insFirst+insCnt) );
  63.  
  64.     ConstCheck( 0, test_construct_pointer_range<TestString>(insFirst, insFirst+insCnt) );
  65.     delete[] insFirst;
  66.  
  67.     WeakCheck( testString, insert_range_tester(testString, testString2.begin(), testString2.end() ) );
  68.     /*
  69.     WeakCheck( testString, test_push_front<TestString>(testString) );
  70.     WeakCheck( testString, test_push_back<TestString>(testString) );
  71.     */
  72.     ConstCheck( 0, test_default_construct<TestString>() );
  73.     // requires _Reserve_t    ConstCheck( 0, test_construct_n<TestString>( random_number(random_base) ) );
  74.     ConstCheck( 0, test_construct_n_instance<TestString>( random_number(random_base) ) );
  75.     ConstCheck( 0, test_construct_iter_range<TestString>( testString2 ) );
  76.     ConstCheck( testString, test_copy_construct<TestString>() );
  77.  
  78.     WeakCheck( testString, test_assign_op<TestString>( testString2 ) );
  79. }
  80.  
  81. #endif // EH_ROPE_IMPLEMENTED
  82.  
  83.