-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBinaryHeap.cpp
More file actions
32 lines (29 loc) · 949 Bytes
/
TestBinaryHeap.cpp
File metadata and controls
32 lines (29 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream.h>
#include "BinaryHeap.h"
#include "dsexceptions.h"
// Test program
int main( )
{
int numItems = 10000;
BinaryHeap<int> h( numItems );
int i = 37;
int x;
try
{
for( i = 37; i != 0; i = ( i + 37 ) % numItems )
h.insert( i );
for( i = 1; i < numItems; i++ )
{
h.deleteMin( x );
if( x != i )
cout << "Oops! " << i << endl;
}
for( i = 37; i != 0; i = ( i + 37 ) % numItems )
h.insert( i );
h.insert( 0 );
h.insert( i = 999999 ); // Should overflow
}
catch( Overflow )
{ cout << "Overflow (expected)! " << i << endl; }
return 0;
}