5752108 [rkeene@sledge /home/rkeene/personal/school/comp-sci-ii/lab3]$ cat -n testdriver.cpp
 1 /* Roy Keene
 2    CS 2314
 3    Section 04
 4    Lab 03
 5    03 Sept 02
 6    testdriver.cpp
 7 */
 8 
 9 #include <iostream>
10 #include "stack.h"
11 
12 #ifndef LAB3_TEST_NUM
13 #define LAB3_TEST_NUM 102400
14 #endif
15 
16 int main(void) {
17     Stack testStack;
18     int i, x;
19 
20     if (testStack.Empty()) { cout << "Stack is empty.\n"; } else { cout << "Stack is NOT empty.\n"; }
21     for (i=0;i<LAB3_TEST_NUM;i++) {
22         testStack.Push(i);
23     }
24     if (testStack.Empty()) { cout << "Stack is empty.\n"; } else { cout << "Stack is NOT empty, top=" << testStack.Top()
	<< "\n"; }
25     for (i=(LAB3_TEST_NUM-1);i>=0;i--) {
26         if ((x=testStack.Pop())!=i) {
27             cout << "Popped " << x << " (should be " << i << ")\n";
28         }
29     }
30     if (testStack.Empty()) { cout << "Stack is empty.\n"; } else { cout << "Stack is NOT empty.\n"; }
31     cout << testStack.Pop() << "\n";
32 }
5752109 [rkeene@sledge /home/rkeene/personal/school/comp-sci-ii/lab3]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2002-09-10 23:04:45