コード例 #1
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 ) );
}
コード例 #2
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 ) );
}
コード例 #3
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 ) );
}
コード例 #4
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 ) );
}
コード例 #5
0
ファイル: test_slist.cpp プロジェクト: aniruddha-loya/NS
void test_slist()
{
	TestSList testSList, testSList2;
	size_t slistSize = random_number(random_base);
	
	while ( testSList.size() < slistSize )
	{
		TestClass x;
		testSList.push_front( x );
		testSList2.push_front( TestClass() );
	}

	StrongCheck( testSList, test_insert_one<TestSList>(testSList) );
	StrongCheck( testSList, test_insert_one<TestSList>(testSList, 0) );
	StrongCheck( testSList, test_insert_one<TestSList>(testSList, (int)testSList.size()) );

	WeakCheck( testSList, test_insert_n<TestSList>(testSList, random_number(random_base) ) );
	WeakCheck( testSList, test_insert_n<TestSList>(testSList, random_number(random_base), 0 ) );
	WeakCheck( testSList, test_insert_n<TestSList>(testSList, random_number(random_base), (int)testSList.size() ) );

	size_t insCnt = random_number(random_base);
	TestClass *insFirst = new TestSList::value_type[1+insCnt];
	WeakCheck( testSList, insert_range_tester(testSList, insFirst, insFirst+insCnt) );

	ConstCheck( 0, test_construct_pointer_range<TestSList>(insFirst, insFirst+insCnt) );
	delete[] insFirst;
	WeakCheck( testSList, test_insert_range<TestSList,TestSList::iterator>(testSList, testSList2.begin(), testSList2.end() ) );
	StrongCheck( testSList, test_push_front<TestSList>(testSList) );
	StrongCheck( testSList, test_slist_sort() );	// Simply to verify strength.	
  
	ConstCheck( 0, test_default_construct<TestSList>() );
	ConstCheck( 0, test_construct_n<TestSList>( random_number(random_base) ) );
	ConstCheck( 0, test_construct_n_instance<TestSList>( random_number(random_base) ) );
	ConstCheck( 0, test_construct_iter_range<TestSList>( testSList2 ) );
	ConstCheck( testSList, test_copy_construct<TestSList>() );
	WeakCheck( testSList, test_assign_op<TestSList>( testSList2 ) );

}
コード例 #6
0
ファイル: test_hash_set.cpp プロジェクト: jiayuehua/STLport
void test_hash_set()
{
# if !(defined (_MSC_VER) && (_MSC_VER < 1100))
	TestSet testSet, testSet2;
	
        const EH_STD::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>() );
	StrongCheck( testSet, test_insert_noresize<TestSet>(testSet) );
#  endif
	WeakCheck( testSet, test_insert_value<TestSet>(testSet) );

	EH_STD::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
}
コード例 #7
0
ファイル: test_bit_vector.cpp プロジェクト: 3runo5ouza/rhodes
/*===================================================================================
  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(random_number(2) != 0);
    testVector2.push_back(random_number(2) != 0);
  }

  // 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) );
}