Dayplanner: seqof_iterator.tst File

Dayplanner: seqof_iterator.tst File


int main(){
    cout << "TESTING SEQUENCE_OF_ITERATOR" << endl;

// Testing Sequence_of_Iterator::CONSTRUCTOR and Sequence_of_Iterator::()
    Sequence_of<int> s;

    for(unsigned o = 1; o <= 25; o++){
        Sequence_of_Iterator<int> i(s);
        if(!(*i.seq == s)){
            cout << "Error -- in Sequence_of_Iterator::Constructor" << endl
                 << "    seq should == the input parameter" << endl;
        };
        if(i.index != 1){
            cout << "Error -- in Sequence_of_Iterator::Constructor" << endl
                 << "    index should initially == 1" << endl;
        };
        int l = 1;
        int k;
        while(i(k)){
            if(k != l){
                cout << "Error -- in Sequence_of_Iterator::()" << endl
                     << "    the return value, k, should have been " << l
                     << " but was " << k << endl;    
            };
            l++;

            int m = 1;
            int n;
            Sequence_of_Iterator<int> j(s);
            while(j(n)){
                if(n != m){
                    cout << "Error -- in Sequence_of_Iterator::()" << endl
                         << "    the return value, n, should have been " << l
                         << " but was " << k << endl;    
                };
                m++;
            };
        };
        s.append(o);

        i.reset();
        if(i.index != 1){
            cout << "Error -- in Sequence_of_Iterator::reset()" << endl
                 << "    index should be 1" << endl;
        };
    };

    // I can't really test the interator for s.size() == MAXUNSIGNED because
    // it takes too much time and too much memory

    wb.report();
    return 0;
};

CS Dept Home Page  BYU Home Page  OSM Home Page
Last updated 8 May 1996.