// Project 2: Sets in C++ // // A Sample main() // // Author: James Kukla // Date: 18 February 2000 // // Purpose: // This file provides an initial test of your Set implementation for // project 2. You should make sure to write some tests of your own to test // all cases possible; these tests are NOT exhaustive. // // Good luck! #include #include "Set.H" void main() { cout << "--- CMSC 202 proj2 Test Suite ---" << endl; cout << "- Beginning testing..." << endl; cout << "- Creating empty sets..." << endl; Set A, B, C; cout << "- Testing isEmpty() (1 point): " << (A.isEmpty() ? "passed" : "failed") << endl; cout << "- Testing add() with 0..11 (5 points): " << endl; for (int i=0; i<12; i++) A.add(i); cout << "\t"; A.print(); cout << endl; B.add(4); B.add(4); B.add(20); cout << "- B should be {4, 20})" << endl; cout << "\t"; B.print(); cout << endl; cout << "- Testing A || B (5 points): " << endl; cout << "\t"; (A||B).print(); cout << endl; cout << "- Testing A && B (5 points):" << endl; cout << "\t"; (A&&B).print(); cout << endl; cout << "- Testing A - B (5 points): " << endl; cout << "\t"; (A-B).print(); cout << endl; cout << "- A is now: " << endl; cout << "\t"; A.print(); cout << endl; cout << "- Removing 20 from B (5 points):" << endl << "- B is now: " << endl; B.remove(20); B.remove(20); cout << "\t"; B.print(); cout << endl; cout << "- Testing A < B (false): " << ((A < B) ? "true" : "false") << " and B < A (true): " << ((B < A) ? "true" : "false") << " (5 points)" << endl; cout << "- Testing A > B (true): " << ((A > B) ? "true" : "false") << " and B > A (false): " << ((B > A) ? "true" : "false") << " (5 points)" << endl; cout << "- Testing A <= B (false): " << ((A <= B) ? "true" : "false") << " and B <= A (true): " << ((B <= A) ? "true" : "false") << " (5 points)" << endl; cout << "- Testing A >= B (true): " << ((A >= B) ? "true" : "false") << " and B >= A (false): " << ((B >= A) ? "true" : "false") << " (5 points)" << endl; cout << "- Testing assignment with A = B (prints A then B) (5 points): " << endl; A = B; cout << "\t"; A.print(); cout << endl; cout << "\t"; B.print(); cout << endl; cout << "- Testing A == B (true): " << ((A == B) ? "true" : "false") << endl; cout << "- (Removing 4 from A. Are A and B still different? (5 points)):" << endl; A.remove(4); cout << "\t"; A.print(); cout << endl; cout << "\t"; B.print(); cout << endl; cout << "- Testing A == B (false): " << ((A == B) ? "true" : "false") << endl; cout << "- Finished testing." << endl; }