/* ___________________ * / \ * | MAP Tester | * \___________________/ * * Author: Dr. Ricardo Morales * * Purpose: Tests the MyStringMap class included in "mystringmap.h" * */ #include #include #include "mystringmap.h" using namespace std; // -------------------------------------------------------------- void test0() { MyStringMap grades; cout << endl; cout << "--- Test 0 ----" << endl; cout << "Is Empty? " << boolalpha << grades.isEmpty() << endl; cout << "Size = " << grades.size() << endl; grades.insert("Nate",'A'); grades.insert("George",'C'); grades.insert("Karl",'F'); grades.insert("John",'B'); grades.insert("Will",'B'); cout << endl; cout << "Is Empty? " << boolalpha << grades.isEmpty() << endl; cout << "Size = " << grades.size() << endl; grades.print(); return; } // -------------------------------------------------------------- void test1() { MyStringMap thelist; cout << endl; cout << "--- Test 1 ----" << endl; cout << "Is Empty? " << boolalpha << thelist.isEmpty() << endl; cout << "Size = " << thelist.size() << endl; thelist.insert("Fry","Naughty"); thelist.insert("Leela","Naughty"); thelist.insert("Hermes","Naughty"); thelist.insert("Qubert","Naughty"); thelist.insert("Zoidberg","Nice"); thelist.insert("Scruffy","Naughty"); thelist.insert("Bender","Naughty"); thelist.insert("Zapp","Naughty"); thelist.insert("Kiff","Naughty"); thelist.insert("Leela","Nice"); cout << endl; cout << "Is Empty? " << boolalpha << thelist.isEmpty() << endl; cout << "Size = " << thelist.size() << endl; thelist.print(); cout << endl; cout << "Testing remove" << endl; cout << "Removing non-Humans" << endl; thelist.remove("Leela"); thelist.remove("Zoidberg"); thelist.remove("Bender"); thelist.remove("Kiff"); thelist.remove("Nixon"); thelist.print(); cout << endl; cout << "Testing Lookup" << endl; try { cout << "Fry? " << thelist.valueOf("Fry") << endl; cout << "Hermes? " << thelist.valueOf("Hermes") << endl; cout << "Qubert? " << thelist.valueOf("Qubert") << endl; cout << "Nixon? "; cout << thelist.valueOf("Nixon") << endl; } catch (string s) { cout << "ERROR : " << s << endl; } cout << endl; //cout << "End of test #1" << endl; return; } // -------------------------------------------------------------- // -------------------------------------------------------------- // -------------------------------------------------------------- int main () { cout << "MAP TESTER!!" << endl; test0(); test1(); //cout << "Q?"; //cin.ignore(); //cin.get(); return 0; }