Example #1
0
//
// Show user what the list contains then show what it ought to contain
// Let the user decide if it is correct
//
void confirm(string name, SortedList& l, string correct)
{
    cout << name << " is now:" << endl;
    l.print();
    cout << "It should be" << endl;
    cout << correct << endl << endl;
}
Example #2
0
void test_findmax()
{
#if FINDMAX
    printf("Running test_findmax\n");
    SortedList l1, l2;
    int	m1, m2;

    readFile(l1, file1);
    readFile(l2, file2);
    m1 = l1.findMax();
    m2 = l2.findMax();
    cout << "list is ";
    l1.print();
    printf("Your max is %d, should be 78\n", m1);
    cout << "list is ";
    l2.print();
    printf("Your max is %d, should be 42\n", m2);
    SortedList eric;
    eric.insert(-100);
    eric.insert(-101);
    eric.insert(-102);
    m1 = eric.findMax();
    cout << "list is ";
    eric.print();
    printf("Your max is %d, should be -100\n", m1);
#endif
}
Example #3
0
void checkfreq(SortedList& l, int num, int correct)
{
    printf("Running checkfreq\n");
    int	f = l.freq(num);;
    cout << "list is ";
    l.print();
    printf("Your freq(%d) rets %d, should be %d\n", num, f, correct);
#endif
}
Example #4
0
void checkwhereis(SortedList& l, int num, string correct)
{
    SortedList result;

    result = l.whereis(num);
    cout << "whereis "<< num << " in " ;
    l.print();
    confirm("your result", result, correct);
#endif
}