Beispiel #1
0
void test2() {
    str_data *t;
    str_data a = str_data( "25" );
    str_data b = str_data( "50" );
    str_data c = str_data( "0" );
    WCPtrOrderedVector<str_data> 	vect( 2 );
    
    vect.exceptions( WCExcept::check_all );
    cout << "PtrOrdered\n";

    test_except( t = vect.removeAt( 0 ), empty_container, "index 1" );
    test_except( t = vect.removeFirst(), empty_container, "index 1b" );
    test_except( t = vect.removeLast(), empty_container, "index 1c" );

    vect.insert( &a );
    vect.insert( &c );

    test_except( t = vect.removeAt( -1 ), index_range, "index 2" );
    test_except( t = vect.removeAt( 2 ), index_range, "index 3" );

    not_happen_except( t = vect.removeLast(), "index 4" );
    not_happen_except( t = vect.removeFirst(), "index 5" );
    cout.flush();
    vect.clear();
}
Beispiel #2
0
void test1() {
    str_data t25 	= str_data( "25" );
    str_data t0 	= str_data( "0" );
    str_data t50 	= str_data( "50" );
    str_data t;

    WCValOrderedVector<str_data> * 	vect
    				= new WCValOrderedVector<str_data>( 2 );
				
    vect->exceptions( WCExcept::check_all );
    cout << "ValOrdered\n";

    test_except( vect->removeAt( 0 ), empty_container, "index 1" );
    test_except( vect->removeFirst(), empty_container, "index 1b" );
    test_except( vect->removeLast(), empty_container, "index 1c" );
    vect->insert( t25 );
    vect->insert( t0 );

    test_except( vect->removeAt( -50 ), index_range, "index 2" );
    test_except( vect->removeAt( 50 ), index_range, "index 3" );

    not_happen_except( vect->removeLast(), "index 4" );
    not_happen_except( vect->removeFirst(), "index 5" );

    vect->clear();
    delete( vect );
    cout.flush();
}
Beispiel #3
0
void test1() {
    WCValSkipList<str_data> skip_list( WCSKIPLIST_PROB_HALF, 4 );
    str_data temp;

    cout << "test1\n";

    WCValSkipListIter<str_data> skip_list_iter;

    if( ++skip_list_iter ) cout << "++iter should have failed";
    str_data temp2;
    if( skip_list_iter.current() != temp2 ) cout << "current should be default value\n";
    if( skip_list_iter.container() != 0 ) cout << "container should return 0\n";

    skip_list_iter.reset();
    if( skip_list_iter() ) cout << "iter() should have failed";

    skip_list_iter.exceptions( WCIterExcept::check_all );

    test_except( ++skip_list_iter, undef_iter, "++1" );
    test_except( skip_list_iter.current(), undef_item, "current1" );
    test_except( skip_list_iter.container(), undef_iter, "container1" );

    skip_list_iter.reset();
    test_except( skip_list_iter(), undef_iter, "()1" );

    skip_list_iter.reset( skip_list );

    test_except( skip_list_iter.current(), undef_item, "current2" );
    if( skip_list_iter.container() != &skip_list ) cout << "container != &skip_list\n";

    if( ++skip_list_iter ) cout << "++iter should return false\n";
    test_except( ++skip_list_iter, undef_iter, "++2" );
    skip_list_iter.reset();
    if( skip_list_iter() ) cout << "iter() should return false\n";
    test_except( skip_list_iter(), undef_iter, "()2" );

    for( int i = 0; i < 20; i++ ) {
	temp = text[ i ];
	skip_list.insert( temp );
    };
    skip_list.forAll( print_val, 0 );
    cout << "\n";

    skip_list_iter.reset();
    test_except( skip_list_iter.current(), undef_item, "current3" );
    while( ++skip_list_iter ) {
	cout << skip_list_iter.current() << " ";
    }
    cout << "\n";

    skip_list_iter.reset();
    while( skip_list_iter() ) {
	cout << skip_list_iter.current() << " ";
    }
}
Beispiel #4
0
void test4() {
    WCPtrSkipListSet<str_data> skip_list;
    str_data temp;

    cout << "\ntest4\n";

    WCPtrSkipListSetIter<str_data> skip_list_iter;

    if( ++skip_list_iter ) cout << "++iter should have failed";
    skip_list_iter.current();
    if( skip_list_iter.container() != 0 ) cout << "container should return 0\n";

    skip_list_iter.reset();
    if( skip_list_iter() ) cout << "iter() should have failed";

    skip_list_iter.exceptions( WCIterExcept::check_all );

    test_except( ++skip_list_iter, undef_iter, "++1" );
    test_except( skip_list_iter.current(), undef_item, "current1" );
    test_except( skip_list_iter.container(), undef_iter, "container1" );

    skip_list_iter.reset();
    test_except( skip_list_iter(), undef_iter, "()1" );

    skip_list_iter.reset( skip_list );

    test_except( skip_list_iter.current(), undef_item, "current2" );
    if( skip_list_iter.container() != &skip_list ) cout << "container != &skip_list\n";

    if( ++skip_list_iter ) cout << "++iter should return false\n";
    test_except( ++skip_list_iter, undef_iter, "++2" );
    skip_list_iter.reset();
    if( skip_list_iter() ) cout << "iter() should return false\n";
    test_except( skip_list_iter(), undef_iter, "()2" );

    for( int i = 0; i < 20; i++ ) {
	skip_list.insert( &str_text[ i ] );
    };
    skip_list.forAll( print_ptr, 0 );
    cout << "\n";

    skip_list_iter.reset();
    test_except( skip_list_iter.current(), undef_item, "current3" );
    while( ++skip_list_iter ) {
	cout << *skip_list_iter.current() << " ";
    }
    cout << "\n";

    skip_list_iter.reset();
    while( skip_list_iter() ) {
	cout << *skip_list_iter.current() << " ";
    }
}
Beispiel #5
0
int main() {
    int a = 1;
    int b = 2;
    int i;

    cout << "Should see 1 2 3 4 5\n";
    WCValOrderedVector<int> vect( 0 );
    vect.exceptions( WCExcept::check_all );
    test_except( vect.insert( a ), resize_required, "1" );
    vect.exceptions( 0 );
    for( i = 0; i < WCDEFAULT_VECTOR_RESIZE_GROW; i++ ){
	vect.insert( a );
    }
    vect.exceptions( WCExcept::check_all );
    test_except( vect.insert( a ), resize_required, "2" )

    WCValOrderedVector<int> vect2( 0, 4 );
    vect2.exceptions( WCExcept::check_all );
    test_except( vect2.insert( a ), resize_required, "3" );
    vect2.exceptions( 0 );

    for( i = 0; i < 4; i++ ){
	vect2.insert( a );
    }
    vect2.exceptions( WCExcept::check_all );
    test_except( vect2.insert( a ), resize_required, "4" );

    WCValOrderedVector<int> vect3( 4, 0 );
    for( i = 0; i < 4; i++ ){
	if( !vect3.insert( a ) ) cout << "insert failed\n";
    }
    if( vect3.insert( a ) ) cout << "insert did not fail\n";
    vect3.exceptions( WCExcept::check_all );
    test_except( vect3.insert( a ), resize_required, "5" );

    vect.clear();
    vect2.clear();
    vect3.clear();
    return 0;
}
Beispiel #6
0
int main (void)
{
    extern void test_config (void);
    extern void test_except (void);
    extern void test_hashtable (void);
    extern void test_memory (void);
    extern void test_scanner (void);
    extern void test_template (void);

#ifdef DEBUG_MALLOC
    GC_find_leak = 1;
#endif
    test_config();
    test_except();
    test_hashtable();
    test_memory();
    test_scanner();
    test_template();

#ifdef DEBUG_MALLOC
    CHECK_LEAKS();
#endif
    return 0;
}
Beispiel #7
0
void test6() {
    WCPtrSkipListDict<str_data,int> skip_list;
    str_data temp;
    int int_array[ 20 ];

    cout << "\ntest6\n";

    WCPtrSkipListDictIter<str_data,int> skip_list_iter;

    if( ++skip_list_iter ) cout << "++iter should have failed";
    str_data temp2;
    skip_list_iter.key();
    skip_list_iter.value();
    if( skip_list_iter.container() != 0 ) cout << "container should return 0\n";

    skip_list_iter.reset();
    if( skip_list_iter() ) cout << "iter() should have failed";

    skip_list_iter.exceptions( WCIterExcept::check_all );

    test_except( ++skip_list_iter, undef_iter, "++1" );
    test_except( skip_list_iter.key(), undef_item, "key 1" );
    test_except( skip_list_iter.value(), undef_item, "value 1" );
    test_except( skip_list_iter.container(), undef_iter, "container1" );

    skip_list_iter.reset();
    test_except( skip_list_iter(), undef_iter, "()1" );

    skip_list_iter.reset( skip_list );

    test_except( skip_list_iter.key(), undef_item, "key 2" );
    test_except( skip_list_iter.value(), undef_item, "value 2" );
    if( skip_list_iter.container() != &skip_list ) cout << "container != &skip_list\n";

    if( ++skip_list_iter ) cout << "++iter should return false\n";
    test_except( ++skip_list_iter, undef_iter, "++2" );
    skip_list_iter.reset();
    if( skip_list_iter() ) cout << "iter() should return false\n";
    test_except( skip_list_iter(), undef_iter, "()2" );

    for( int i = 0; i < 20; i++ ) {
	int_array[ i ] = i;
	skip_list.insert( &str_text[ i ], &int_array[ i ] );
    };
    skip_list.forAll( print_dict_ptr, 0 );
    cout << "\n";

    skip_list_iter.reset();
    test_except( skip_list_iter.key(), undef_item, "key 3" );
    test_except( skip_list_iter.value(), undef_item, "value 3" );
    while( ++skip_list_iter ) {
	cout << *skip_list_iter.key() << ":";
	cout << *skip_list_iter.value() << " ";
    }
    test_except( skip_list_iter.key(), undef_item, "key 4" );
    test_except( skip_list_iter.value(), undef_item, "value 4" );
    cout << "\n";

    skip_list_iter.reset();
    while( skip_list_iter() ) {
	cout << *skip_list_iter.key() << ":";
	cout << *skip_list_iter.value() << " ";
    }
}