os/ossrv/genericopenlibs/cppstdlib/stl/test/eh/test_hash_set.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_hash_set.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,127 @@
     1.4 +/***********************************************************************************
     1.5 +  test_hash_set.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 +#include "Tests.h"
    1.20 +
    1.21 +#if defined( EH_HASHED_CONTAINERS_IMPLEMENTED )
    1.22 +
    1.23 +#  include <hash_set>
    1.24 +
    1.25 +#include "TestClass.h"
    1.26 +#include "LeakCheck.h"
    1.27 +#include "test_construct.h"
    1.28 +#include "test_assign_op.h"
    1.29 +#include "test_push_back.h"
    1.30 +#include "test_insert.h"
    1.31 +#include "test_push_front.h"
    1.32 +#include "ThrowCompare.h"
    1.33 +#include "test_hash_resize.h"
    1.34 +
    1.35 +typedef EH_STD::__hash_multiset__<TestClass, ThrowHash, ThrowEqual,
    1.36 +  eh_allocator(TestClass) > TestMultiSet;
    1.37 +
    1.38 +inline multiset_tag
    1.39 +container_category(const TestMultiSet&)
    1.40 +{
    1.41 +  return multiset_tag();
    1.42 +}
    1.43 +
    1.44 +void test_hash_multiset()
    1.45 +{
    1.46 +# if !(defined (_MSC_VER) && (_MSC_VER < 1100))
    1.47 +  TestMultiSet testMultiSet, testMultiSet2;
    1.48 +
    1.49 +        const size_t hash_setSize = random_number(random_base);
    1.50 +
    1.51 +  while ( testMultiSet.size() < hash_setSize )
    1.52 +  {
    1.53 +    TestMultiSet::value_type x;
    1.54 +    testMultiSet.insert( x );
    1.55 +    testMultiSet2.insert( TestMultiSet::value_type() );
    1.56 +  }
    1.57 +
    1.58 +#  if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
    1.59 +  WeakCheck( testMultiSet, test_hash_resize<TestMultiSet>() );
    1.60 +  // TestMultiSet == TestMultiSet: no such operator! - ptr
    1.61 +  // StrongCheck( testMultiSet, test_insert_noresize<TestMultiSet>(testMultiSet) );
    1.62 +#  endif
    1.63 +  WeakCheck( testMultiSet, test_insert_value<TestMultiSet>(testMultiSet) );
    1.64 +
    1.65 +  size_t insCnt = random_number(random_base);
    1.66 +  TestMultiSet::value_type *insFirst = new TestMultiSet::value_type[1+insCnt];
    1.67 +  WeakCheck( testMultiSet, insert_range_tester(testMultiSet, insFirst, insFirst+insCnt) );
    1.68 +  ConstCheck( 0, test_construct_pointer_range<TestMultiSet>(insFirst, insFirst+insCnt) );
    1.69 +  delete[] insFirst;
    1.70 +
    1.71 +  WeakCheck( testMultiSet, insert_range_tester(testMultiSet, testMultiSet2.begin(), testMultiSet2.end() ) );
    1.72 +
    1.73 +  ConstCheck( 0, test_default_construct<TestMultiSet>() );
    1.74 +#  if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
    1.75 +  ConstCheck( 0, test_construct_iter_range_n<TestMultiSet>( testMultiSet2 ) );
    1.76 +#  endif
    1.77 +  ConstCheck( testMultiSet, test_copy_construct<TestMultiSet>() );
    1.78 +
    1.79 +  WeakCheck( testMultiSet, test_assign_op<TestMultiSet>( testMultiSet2 ) );
    1.80 +# endif
    1.81 +}
    1.82 +
    1.83 +typedef EH_STD::__hash_set__<TestClass, ThrowHash, ThrowEqual, eh_allocator(TestClass) > TestSet;
    1.84 +
    1.85 +inline set_tag
    1.86 +container_category(const TestSet&)
    1.87 +{
    1.88 +  return set_tag();
    1.89 +}
    1.90 +
    1.91 +void test_hash_set()
    1.92 +{
    1.93 +# if !(defined (_MSC_VER) && (_MSC_VER < 1100))
    1.94 +  TestSet testSet, testSet2;
    1.95 +
    1.96 +        const size_t hash_setSize = random_number(random_base);
    1.97 +
    1.98 +  while ( testSet.size() < hash_setSize )
    1.99 +  {
   1.100 +    TestSet::value_type x;
   1.101 +    testSet.insert( x );
   1.102 +    testSet2.insert( TestSet::value_type() );
   1.103 +  }
   1.104 +
   1.105 +#  if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
   1.106 +  WeakCheck( testSet, test_hash_resize<TestSet>() );
   1.107 +  // TestMultiSet == TestMultiSet: no such operator! - ptr
   1.108 +  // StrongCheck( testSet, test_insert_noresize<TestSet>(testSet) );
   1.109 +#  endif
   1.110 +  WeakCheck( testSet, test_insert_value<TestSet>(testSet) );
   1.111 +
   1.112 +  size_t insCnt = random_number(random_base);
   1.113 +  TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt];
   1.114 +  WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) );
   1.115 +  ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) );
   1.116 +  delete[] insFirst;
   1.117 +
   1.118 +  WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) );
   1.119 +
   1.120 +  ConstCheck( 0, test_default_construct<TestSet>() );
   1.121 +#  if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
   1.122 +  ConstCheck( 0, test_construct_iter_range_n<TestSet>( testSet2 ) );
   1.123 +#  endif
   1.124 +  ConstCheck( testSet, test_copy_construct<TestSet>() );
   1.125 +
   1.126 +  WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) );
   1.127 +# endif
   1.128 +}
   1.129 +
   1.130 +#endif  // EH_HASHED_CONTAINERS_IMPLEMENTED