001
27.09.2006, 21:19 Uhr
mathon
|
Hier ist das test-programm, das ich verwende:
C++: |
int test5( ) { sequence original; // A sequence that we'll copy. double items[2*original.DEFAULT_CAPACITY]; size_t i;
// Set up the items array to conatin 1...2*DEFAULT_CAPACITY. for (i = 1; i <= 2*original.DEFAULT_CAPACITY; i++) items[i-1] = i; // Test copying of an empty sequence. After the copying, we change the original. cout << "Copy constructor test: for an empty sequence." << endl; sequence copy1(original); original.attach(1); // Changes the original sequence, but not the copy. if (!correct(copy1, 0, 0, items)) return 0;
// Test copying of a sequence with current item at the tail. cout << "Copy constructor test: for a sequence with cursor at tail." << endl; for (i=2; i <= 2*original.DEFAULT_CAPACITY; i++) original.attach(i); cout << "SIZE: " << original.size() << endl; sequence copy2(original); original.start( ); original.advance( ); original.remove_current( ); // Removes 2 from the original, but not the copy. if (!correct (copy2, 2*original.DEFAULT_CAPACITY, 2*original.DEFAULT_CAPACITY-1, items) ) return 0;
// Test copying of a sequence with cursor near the middle. cout << "Copy constructor test: for a sequence with cursor near middle." << endl; original.insert(2); for (i = 1; i < original.DEFAULT_CAPACITY; i++) original.advance( ); // Cursor is now at location [DEFAULT_CAPACITY] (counting [0] as the first spot). sequence copy3(original); original.start( ); original.advance( ); original.remove_current( ); // Removes 2 from the original, but not the copy. if (!correct (copy3, 2*original.DEFAULT_CAPACITY, original.DEFAULT_CAPACITY, items) ) return 0;
// Test copying of a sequence with cursor at the front. cout << "Copy constructor test: for a sequence with cursor near middle." << endl; original.insert(2); original.start( ); // Cursor is now at the front. sequence copy4(original); original.start( ); original.advance( ); original.remove_current( ); // Removes 2 from the original, but not the copy. if (!correct (copy4, 2*original.DEFAULT_CAPACITY, 0, items) ) return 0;
// Test copying of a sequence with no current item. cout << "Copy constructor test: for a sequence with no current item." << endl; original.insert(2); while (original.is_item( )) original.advance( ); // There is now no current item. sequence copy5(original); original.start( ); original.advance( ); original.remove_current( ); // Removes 2 from the original, but not the copy. if (!correct (copy5, 2*original.DEFAULT_CAPACITY, 2*original.DEFAULT_CAPACITY, items) ) return 0; }
|
Nach der Zeile cout << "Copy constructor test: for a sequence with cursor near middle." << endl; bricht das Programm ab und es erscheint ein Popup-Fenster, wo steht, dass das Programm einen Fehler festgestellt hat und beendet werden musste.
Ich glaube der Fehler passiert eigentlich bei dem insert statement danach.
Hat jemand von euch ne ahnung..? :confused:
matti Dieser Post wurde am 27.09.2006 um 22:16 Uhr von FloSoft editiert. |