コード例 #1
0
ファイル: test_set.cpp プロジェクト: hoangduit/reactos
void test_set() {
  TestSet testSet, testSet2;

  const size_t setSize = random_number(random_base);

  while ( testSet.size() < setSize ) {
    TestSet::value_type x;
    testSet.insert( x );
    testSet2.insert( TestSet::value_type() );
  }
  StrongCheck( testSet, test_insert_value<TestSet>(testSet) );

  size_t insCnt = random_number(random_base);
  TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt];

  WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) );

  ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) );
  delete[] insFirst;
  WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) );

  ConstCheck( 0, test_default_construct<TestSet>() );
  ConstCheck( 0, test_construct_iter_range<TestSet>( testSet2 ) );
  ConstCheck( testSet, test_copy_construct<TestSet>() );
  WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) );
}
コード例 #2
0
ファイル: test_map.cpp プロジェクト: rickyharis39/nolf2
void test_map()
{
    TestMap testMap, testMap2;
	
    const EH_STD::size_t mapSize = random_number(random_base);
	
    while ( testMap.size() < mapSize )
    {
        TestMap::value_type x;
        testMap.insert( x );
        testMap2.insert( TestMap::value_type() );
    }

    StrongCheck( testMap, test_insert_value<TestMap>(testMap) );

    EH_STD::size_t insCnt = random_number(random_base);
    TestMap::value_type *insFirst = new TestMap::value_type[1+insCnt];

    WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );

    ConstCheck( 0, test_construct_pointer_range<TestMap>(insFirst, insFirst+insCnt) );
    delete[] insFirst;

    WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) );
    ConstCheck( 0, test_default_construct<TestMap>() );
    ConstCheck( 0, test_construct_iter_range<TestMap>( testMap2 ) );
    ConstCheck( testMap, test_copy_construct<TestMap>() );
    WeakCheck( testMap, test_assign_op<TestMap>( testMap2 ) );
}
コード例 #3
0
/*===================================================================================
	test_bit_vector

	EFFECTS:  Performs tests on bit vectors
====================================================================================*/
void test_bit_vector()
{
	#define __WORD_BIT (int(CHAR_BIT*sizeof(unsigned int)))
	
	// Make some bit vectors to work with.
    BitVector emptyVector;
    BitVector testVector, testVector2;
    
    EH_ASSERT( testVector.size() == 0 );
    
    size_t BitVectorSize = random_number( random_base );
    // Half the time, choose a size that will guarantee immediate reallocation
    if ( random_number(2) )
    	BitVectorSize = BitVectorSize / __WORD_BIT * __WORD_BIT;
	
    EH_ASSERT( testVector.size() == 0 );
    testVector.reserve(BitVectorSize);
    EH_ASSERT( testVector.size() == 0 );
    while ( testVector.size() < BitVectorSize )
    {
        testVector.push_back( bool(random_number(2)) );
        testVector2.push_back( bool(random_number(2)) );
    }
	
	// Test insertions
    StrongCheck( testVector, test_insert_one<BitVector>(testVector) );
    StrongCheck( testVector, test_insert_one<BitVector>(testVector,0) );
    StrongCheck( testVector, test_insert_one<BitVector>(testVector, (int)testVector.size()) );

    StrongCheck( testVector, test_insert_n<BitVector>(testVector, random_number(random_base) ) );
    StrongCheck( testVector, test_insert_n<BitVector>(testVector, random_number(random_base),0 ) );
    StrongCheck( testVector, test_insert_n<BitVector>(testVector, random_number(random_base), (int)testVector.size()) );
# if 0	
	// Allocate some random bools to insert
    size_t insCnt = 1 + random_number(random_base);
    bool *insFirst = new BitVector::value_type[insCnt];
    for ( size_t n = 0; n < insCnt; n++ )
        insFirst[n] = random_number(2);
    StrongCheck( testVector, insert_range_tester(testVector, insFirst, insFirst+insCnt) );
    StrongCheck( testVector, insert_range_at_begin_tester(testVector, insFirst, insFirst+insCnt) );
    StrongCheck( testVector, insert_range_at_end_tester(testVector, insFirst, insFirst+insCnt) );
    ConstCheck( 0, test_construct_pointer_range<BitVector>( insFirst, insFirst + insCnt ) );
    delete[] insFirst;
# endif
    StrongCheck( testVector, insert_range_tester(testVector, testVector2.begin(), testVector2.end() ) );
    StrongCheck( testVector, insert_range_at_begin_tester(testVector, testVector2.begin(), 
							  testVector2.end() ) );
    StrongCheck( testVector, insert_range_at_end_tester(testVector, testVector2.begin(), 
							  testVector2.end() ) );
    StrongCheck( testVector, test_BitVector_reserve( testVector.capacity() + random_number(50) ) );
    StrongCheck( testVector, test_push_back<BitVector>(testVector) );
    StrongCheck( emptyVector, test_push_back<BitVector>(emptyVector) );	

    ConstCheck( 0, test_default_construct<BitVector>() );
    ConstCheck( 0, test_construct_n<BitVector>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_n_instance<BitVector>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<BitVector>( testVector2 ) );
    ConstCheck( testVector, test_copy_construct<BitVector>() );
    WeakCheck( testVector, test_assign_op<BitVector>( testVector2 ) );
}
コード例 #4
0
void test_deque()
{
    EH_STD::size_t dequeSize = random_number(random_base);
    TestDeque emptyDeque;
    TestDeque testDeque, testDeque2;
    while ( testDeque.size() < dequeSize )
    {
        DQTestClass x;
        testDeque.push_back( x );
        testDeque2.push_back( DQTestClass() );
    }

    ConstCheck( testDeque, test_copy_construct<TestDeque>() );
    WeakCheck( testDeque, test_insert_one<TestDeque>(testDeque) );
    StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque,0) );
    StrongCheck( testDeque, test_insert_one<TestDeque>(testDeque, testDeque.size()) );

    WeakCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base) ) );
    StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), 0 ) );
    StrongCheck( testDeque, test_insert_n<TestDeque>(testDeque, random_number(random_base), testDeque.size() ) );

    EH_STD::size_t insCnt = random_number(random_base);
    DQTestClass *insFirst = new TestDeque::value_type[insCnt+1];

    WeakCheck( testDeque, insert_range_tester(testDeque, (DQTestClass *)insFirst, 
					      insFirst+insCnt) );
    StrongCheck( testDeque, insert_range_at_begin_tester(testDeque, (DQTestClass *)insFirst,
							 insFirst+insCnt) );
    StrongCheck( testDeque, insert_range_at_end_tester(testDeque, (DQTestClass *)insFirst, 
						       insFirst+insCnt) );

    ConstCheck( 0, test_construct_pointer_range<TestDeque>( (DQTestClass *)insFirst, 
							    insFirst+insCnt ) );
    delete[] insFirst;

    WeakCheck( testDeque, insert_range_tester(testDeque, testDeque2.begin(), testDeque2.end() ) );

    StrongCheck( testDeque, test_push_back<TestDeque>(testDeque) );
    StrongCheck( emptyDeque, test_push_back<TestDeque>(emptyDeque) );
    StrongCheck( testDeque, test_push_front<TestDeque>(testDeque) );
    StrongCheck( emptyDeque, test_push_front<TestDeque>(emptyDeque) );


    ConstCheck( 0, test_default_construct<TestDeque>() );
    ConstCheck( 0, test_construct_n<TestDeque>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_n_instance<TestDeque>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<TestDeque>( testDeque2 ) );

    testDeque2.resize( testDeque.size() * 3 / 2 );
    WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) );
    testDeque2.resize( testDeque.size() * 2 / 3 );
    WeakCheck( testDeque, test_assign_op<TestDeque>( testDeque2 ) );
}
コード例 #5
0
ファイル: test_vector.cpp プロジェクト: rickyharis39/nolf2
void test_vector()
{

    ConstCheck( 0, test_construct_n<TestVector>( random_number(random_base) ) );
   
    TestVector emptyVector;
    TestVector testVector, testVector2;
    EH_STD::size_t vectorSize = random_number(random_base);
	
    testVector.reserve(vectorSize*4);
    while ( testVector.size() < vectorSize )
    {
        TestClass x;
        testVector.push_back( x );
        testVector2.push_back( TestClass() );
    }
	
    EH_STD::size_t insCnt = random_number(random_base);
    TestClass *insFirst = new TestVector::value_type[1+ insCnt];

    ConstCheck( 0, test_construct_pointer_range<TestVector>(insFirst, insFirst+insCnt) );

    WeakCheck( testVector, insert_range_tester(testVector, insFirst, insFirst+insCnt) );
    WeakCheck( testVector, insert_range_at_begin_tester(testVector, insFirst, insFirst+insCnt) );
    WeakCheck( testVector, insert_range_at_end_tester(testVector, insFirst, insFirst+insCnt) );
    delete[] insFirst;

    WeakCheck( testVector, test_insert_one<TestVector>(testVector) );
    WeakCheck( testVector, test_insert_one<TestVector>(testVector, 0) );
    WeakCheck( testVector, test_insert_one<TestVector>(testVector, (int)testVector.size()) );

    WeakCheck( testVector, test_insert_n<TestVector>(testVector, random_number(random_base) ) );
    WeakCheck( testVector, test_insert_n<TestVector>(testVector, random_number(random_base), 0 ) );
    WeakCheck( testVector, test_insert_n<TestVector>(testVector, random_number(random_base), (int)testVector.size() ) );

    WeakCheck( testVector, insert_range_tester(testVector, testVector2.begin(), testVector2.end() ) );
	

    StrongCheck( testVector, test_reserve( testVector.capacity() + random_number(random_base) ) );
    StrongCheck( testVector, test_push_back<TestVector>(testVector) );
    StrongCheck( emptyVector, test_push_back<TestVector>(emptyVector) );

    ConstCheck( 0, test_default_construct<TestVector>() );
    ConstCheck( 0, test_construct_n_instance<TestVector>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<TestVector>( testVector2 ) );
    ConstCheck( testVector, test_copy_construct<TestVector>() );

    testVector2.resize( testVector.size() * 3 / 2 );
    WeakCheck( testVector, test_assign_op<TestVector>( testVector2 ) );
    testVector2.clear();
    testVector2.resize( testVector.size() * 2 / 3 );
    WeakCheck( testVector, test_assign_op<TestVector>( testVector2 ) );
}
コード例 #6
0
ファイル: test_rope.cpp プロジェクト: 3runo5ouza/rhodes
void test_rope()
{
    TestRope testRope, testRope2;
    size_t ropeSize = random_number(random_base);

    while ( testRope.size() < ropeSize )
    {
        TestRope::value_type x = TestRope::value_type(random_number(random_base));  // initialize before use
        testRope.push_back( x );
        testRope2.push_back( TestRope::value_type() );
    }
    WeakCheck( testRope, test_insert_one<TestRope>(testRope) );
    WeakCheck( testRope, test_insert_one<TestRope>(testRope, 0) );
    WeakCheck( testRope, test_insert_one<TestRope>(testRope, (int)testRope.size()) );

    WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base) ) );
    WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), 0 ) );
    WeakCheck( testRope, test_insert_n<TestRope>(testRope, random_number(random_base), (int)testRope.size() ) );

    size_t insCnt = random_number(random_base);
    TestRope::value_type *insFirst = new TestRope::value_type[1+insCnt];

    WeakCheck( testRope, insert_range_tester(testRope, insFirst, insFirst+insCnt) );
    WeakCheck( testRope, insert_range_at_begin_tester(testRope, insFirst, insFirst+insCnt) );
    WeakCheck( testRope, insert_range_at_end_tester(testRope, insFirst, insFirst+insCnt) );

    ConstCheck( 0, test_construct_pointer_range<TestRope>(insFirst, insFirst+insCnt) );
    delete[] insFirst;

    WeakCheck( testRope, insert_range_tester(testRope, testRope2.begin(), testRope2.end() ) );

    WeakCheck( testRope, test_push_front<TestRope>(testRope) );
    WeakCheck( testRope, test_push_back<TestRope>(testRope) );

    ConstCheck( 0, test_default_construct<TestRope>() );

// dwa 1/25/00 - not actually valid for rope, because it doesn't
// have the constructor in question! The code will compile, but with the
// wrong result (the constructor that gets used does something different).

//  ConstCheck( 0, test_construct_n<TestRope>( random_number(random_base) ) );

    ConstCheck( 0, test_construct_n_instance<TestRope>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<TestRope>( testRope2 ) );
    ConstCheck( testRope, test_copy_construct<TestRope>() );

    WeakCheck( testRope, test_assign_op<TestRope>( testRope2 ) );
}
コード例 #7
0
void test_list()
{
    TestList testList, testList2;
    size_t listSize = random_number(random_base);
  
    while ( testList.size() < listSize )
    {
        TestClass x;
        testList.push_back( x );
        testList2.push_back( TestClass() );
    }

    StrongCheck( testList, test_insert_one<TestList>(testList) );
    StrongCheck( testList, test_insert_one<TestList>(testList, 0) );
    StrongCheck( testList, test_insert_one<TestList>(testList, (int)testList.size()) );

    WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base) ) );
    WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base), 0 ) );
    WeakCheck( testList, test_insert_n<TestList>(testList, random_number(random_base), (int)testList.size() ) );
  
    size_t insCnt = random_number(random_base);
    TestClass *insFirst = new TestList::value_type[1+insCnt];

    WeakCheck( testList, insert_range_tester(testList, insFirst, insFirst+insCnt) );
    WeakCheck( testList, insert_range_at_begin_tester(testList, insFirst, insFirst+insCnt) );
    WeakCheck( testList, insert_range_at_end_tester(testList, insFirst, insFirst+insCnt) );

    ConstCheck( 0, test_construct_pointer_range<TestList>(insFirst, insFirst+insCnt) );
    delete[] insFirst;

    WeakCheck( testList, insert_range_tester(testList, testList2.begin(), testList2.end() ) );

    StrongCheck( testList, test_push_front<TestList>(testList) );
    StrongCheck( testList, test_push_back<TestList>(testList) );

    StrongCheck( testList, test_list_sort() );  // Simply to verify strength.
       
    ConstCheck( 0, test_default_construct<TestList>() );
    ConstCheck( 0, test_construct_n<TestList>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_n_instance<TestList>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<TestList>( testList2 ) );
    ConstCheck( testList, test_copy_construct<TestList>() );

    WeakCheck( testList, test_assign_op<TestList>( testList2 ) );
}
コード例 #8
0
ファイル: test_string.cpp プロジェクト: rickyharis39/nolf2
void test_string()
{
    TestString testString, testString2;
    EH_STD::size_t ropeSize = random_number(random_base);
	
    while ( testString.size() < ropeSize )
    {
        TestString::value_type x = TestString::value_type(random_number(random_base)) ;	// initialize before use
        testString.append(1, x );
        testString2.append(1, TestString::value_type() );
    }
    WeakCheck( testString, test_insert_one<TestString>(testString) );
    WeakCheck( testString, test_insert_one<TestString>(testString, 0) );
    WeakCheck( testString, test_insert_one<TestString>(testString, (int)testString.size()) );

    WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base) ) );
    WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), 0 ) );
    WeakCheck( testString, test_insert_n<TestString>(testString, random_number(random_base), (int)testString.size() ) );
	
    EH_STD::size_t insCnt = random_number(random_base);
    TestString::value_type *insFirst = new TestString::value_type[1+insCnt];

    WeakCheck( testString, insert_range_tester(testString, insFirst, insFirst+insCnt) );
    WeakCheck( testString, insert_range_at_begin_tester(testString, insFirst, insFirst+insCnt) );
    WeakCheck( testString, insert_range_at_end_tester(testString, insFirst, insFirst+insCnt) );

    ConstCheck( 0, test_construct_pointer_range<TestString>(insFirst, insFirst+insCnt) );
    delete[] insFirst;

    WeakCheck( testString, insert_range_tester(testString, testString2.begin(), testString2.end() ) );
    /*
    WeakCheck( testString, test_push_front<TestString>(testString) );
    WeakCheck( testString, test_push_back<TestString>(testString) );
    */
    ConstCheck( 0, test_default_construct<TestString>() );
    // requires _Reserve_t    ConstCheck( 0, test_construct_n<TestString>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_n_instance<TestString>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<TestString>( testString2 ) );
    ConstCheck( testString, test_copy_construct<TestString>() );

    WeakCheck( testString, test_assign_op<TestString>( testString2 ) );
}
コード例 #9
0
ファイル: test_valarray.cpp プロジェクト: Arkshine/NS
void test_rope()
{
    TestValarray testValarray, testValarray2;
    size_t ropeSize = random_number(random_base);
	
    while ( testValarray.size() < ropeSize )
    {
        TestValarray::value_type x = random_number(random_base) ;	// initialize before use
        testValarray.push_back( x );
        testValarray2.push_back( TestValarray::value_type() );
    }
    WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray) );
    WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, 0) );
    WeakCheck( testValarray, test_insert_one<TestValarray>(testValarray, testValarray.size()) );

    WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base) ) );
    WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), 0 ) );
    WeakCheck( testValarray, test_insert_n<TestValarray>(testValarray, random_number(random_base), testValarray.size() ) );
	
    size_t insCnt = random_number(random_base);
    TestValarray::value_type *insFirst = new TestValarray::value_type[1+insCnt];

    WeakCheck( testValarray, insert_range_tester(testValarray, insFirst, insFirst+insCnt) );
    WeakCheck( testValarray, insert_range_at_begin_tester(testValarray, insFirst, insFirst+insCnt) );
    WeakCheck( testValarray, insert_range_at_end_tester(testValarray, insFirst, insFirst+insCnt) );

    ConstCheck( 0, test_construct_pointer_range<TestValarray>(insFirst, insFirst+insCnt) );
    delete[] insFirst;

    WeakCheck( testValarray, insert_range_tester(testValarray, testValarray2.begin(), testValarray2.end() ) );

    WeakCheck( testValarray, test_push_front<TestValarray>(testValarray) );
    WeakCheck( testValarray, test_push_back<TestValarray>(testValarray) );

    ConstCheck( 0, test_default_construct<TestValarray>() );
    ConstCheck( 0, test_construct_n<TestValarray>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_n_instance<TestValarray>( random_number(random_base) ) );
    ConstCheck( 0, test_construct_iter_range<TestValarray>( testValarray2 ) );
    ConstCheck( testValarray, test_copy_construct<TestValarray>() );

    WeakCheck( testValarray, test_assign_op<TestValarray>( testValarray2 ) );
}
コード例 #10
0
ファイル: test_hash_set.cpp プロジェクト: hoangduit/reactos
void test_hash_set()
{
# if !(defined (_MSC_VER) && (_MSC_VER < 1100))
  TestSet testSet, testSet2;

        const size_t hash_setSize = random_number(random_base);

  while ( testSet.size() < hash_setSize )
  {
    TestSet::value_type x;
    testSet.insert( x );
    testSet2.insert( TestSet::value_type() );
  }

#  if defined( EH_HASH_CONTAINERS_SUPPORT_RESIZE )
  WeakCheck( testSet, test_hash_resize<TestSet>() );
  // TestMultiSet == TestMultiSet: no such operator! - ptr
  // StrongCheck( testSet, test_insert_noresize<TestSet>(testSet) );
#  endif
  WeakCheck( testSet, test_insert_value<TestSet>(testSet) );

  size_t insCnt = random_number(random_base);
  TestSet::value_type *insFirst = new TestSet::value_type[1+insCnt];
  WeakCheck( testSet, insert_range_tester(testSet, insFirst, insFirst+insCnt) );
  ConstCheck( 0, test_construct_pointer_range<TestSet>(insFirst, insFirst+insCnt) );
  delete[] insFirst;

  WeakCheck( testSet, insert_range_tester(testSet, testSet2.begin(), testSet2.end() ) );

  ConstCheck( 0, test_default_construct<TestSet>() );
#  if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION
  ConstCheck( 0, test_construct_iter_range_n<TestSet>( testSet2 ) );
#  endif
  ConstCheck( testSet, test_copy_construct<TestSet>() );

  WeakCheck( testSet, test_assign_op<TestSet>( testSet2 ) );
# endif
}