Please send questions to
st10@humboldt.edu .
//---------------------------------------------------------------
// File: test_htable.cpp
// Name: Sharon M. Tuttle
// last modified: 2-10-05
//
// Purpose: tester for class htable
//--------------------------------------------------------------
#include <iostream>
#include "htable.h"
using namespace std;
int main()
{
// declarations
htable hashy;
cout << endl;
cout << "Testing class htable..." << endl;
cout << endl;
cout << "AT THE BEGINNING: should see 23 NU's: " << endl;
cout << "-------------------------------------";
hashy.print_guts();
cout << endl;
// verify the constructors and test the accessors/observers
// at the same time
cout << "VERIFYING CONSTRUCTORS/ACCESSORS/OBSERVERS:" << endl;
cout << endl;
cout << "1's mean test passed, 0's mean test failed:" << endl;
cout << "-------------------------------------------" << endl;
cout << (hashy.is_empty() == true) << endl;
cout << (hashy.is_full() == false) << endl;
cout << (hashy.is_in_table(24) == false) << endl;
cout << (hashy.get_capacity() == 23) << endl;
cout << (hashy.get_size() == 0) << endl;
// verifying the modifiers
cout << endl;
cout << "VERIFYING MODIFIERS:" << endl;
cout << endl;
cout << "1's mean test passed, 0's mean test failed:" << endl;
cout << "-------------------------------------------" << endl;
// note: in a way, these are going to partially test my
// hash function...
hashy.insert(27);
hashy.insert(23);
hashy.insert(4);
hashy.insert(24);
hashy.insert(553);
hashy.insert(45);
hashy.insert(22);
cout << (hashy.is_empty() == false) << endl;
cout << (hashy.is_full() == false) << endl;
cout << (hashy.is_in_table(27) == true) << endl;
cout << (hashy.is_in_table(23) == true) << endl;
cout << (hashy.is_in_table(4) == true) << endl;
cout << (hashy.is_in_table(24) == true) << endl;
cout << (hashy.is_in_table(553) == true) << endl;
cout << (hashy.is_in_table(45) == true) << endl;
cout << (hashy.is_in_table(22) == true) << endl;
cout << (hashy.is_in_table(46) == false) << endl;
cout << (hashy.get_size() == 7) << endl;
cout << endl;
cout << "NOW: should contain 27, 23, 4, 24, 553, 45, 22: " << endl;
cout << "-------------------------------------------";
hashy.print_guts();
cout << endl;
hashy.remove(23);
hashy.remove(553);
cout << (hashy.is_in_table(23) == false) << endl;
cout << (hashy.is_in_table(553) == false) << endl;
cout << (hashy.get_size() == 5) << endl;
cout << endl;
cout << "NOW: should contain 27, 4, 24, 45, 22, and two PU's: " << endl;
cout << "-------------------------------------------";
hashy.print_guts();
cout << endl;
hashy.insert(70);
cout << (hashy.is_in_table(70) == true) << endl;
cout << (hashy.get_size() == 6) << endl;
cout << endl;
cout << "NOW: should contain 27, 4, 24, 45, 22, 70 and one PU: " << endl;
cout << "-------------------------------------------";
hashy.print_guts();
cout << endl;
return EXIT_SUCCESS;
}