Please send questions to
st10@humboldt.edu .
//---------------------------------------------------------------
// File: test_count_seql.cpp
// Name: Sharon M. Tuttle
// last modified: 2-7-05
//
// Purpose: tester for function count_seql.cpp
//--------------------------------------------------------------
#include <iostream>
#include "count_seql.h"
using namespace std;
int main()
{
// set-up declarations
int arr1[] = {1, 5, 8, 22, 58, 200, 202, 356};
int count = 0;
// tests and associated cout's
cout << endl;
cout << "Testing function count_seql..." << endl;
cout << endl;
cout << "1's mean test passed, 0's mean test failed:" << endl;
cout << "-------------------------------------------" << endl;
cout << (count_seql(arr1, 0, 7, 22, count) == 3) << endl;
cout << (count == 4) << endl;
count = 0;
cout << (count_seql(arr1, 0, 7, 23, count) == -1) << endl;
cout << (count == 8) << endl;
count = 0;
cout << (count_seql(arr1, 3, 5, 58, count) == 4) << endl;
cout << (count == 2) << endl;
count = 0;
cout << (count_seql(arr1, 3, 5, 97, count) == -1) << endl;
cout << (count == 3) << endl;
// let's try a BIG array... [for ADDITIONAL, "bonus" testing!]
int big[10000];
for (int i=0; i < 10000; i++)
{
big[i] = i*2;
}
int target;
cout << "in array of even numbers from 0 to 19998, " << endl;
cout << " enter a value to search for: " ;
cin >> target;
cout << "found " << target << " at: ";
int where;
count = 0;
where = count_seql(big, 0, 9999, target, count);
cout << where;
cout << " ...and it took: " << count << " comparisons." << endl;
cout << endl;
return EXIT_SUCCESS;
}