-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test_deque_as_array.cpp
64 lines (57 loc) · 1.45 KB
/
Test_deque_as_array.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "Deque_as_array.h"
#include "Exception.h"
using namespace std;
int main() {
Deque_as_array foo(15);
assert(foo.empty());
assert(foo.empty() != 0);
assert(foo.size() == 0);
foo.enqueue_head(1);
foo.enqueue_head(2);
foo.enqueue_head(3);
foo.enqueue_head(334);
foo.enqueue_head(35);
foo.enqueue_tail(12);
foo.enqueue_tail(11);
foo.enqueue_tail(13);
foo.enqueue_tail(14);
foo.enqueue_tail(90);
assert(foo.head() == 35);
assert(foo.size() == 10);
assert(foo.capacity() == 15);
assert(foo.tail() != 14);
assert(foo.tail() == 90);
assert(foo.empty() != 1);
foo.enqueue_head(10);
assert(foo.dequeue_head() == 10);
assert(foo.dequeue_tail() == 90);
assert(foo.dequeue_tail() == 14);
assert(foo.head() == 35);
assert(foo.dequeue_head() == 35);
assert(foo.head() == 334);
assert(foo.tail() == 13);
foo.enqueue_head(111);
foo.enqueue_head(121);
foo.enqueue_tail(122);
foo.enqueue_head(129);
foo.enqueue_tail(127);
foo.enqueue_head(137);
foo.enqueue_head(147);
foo.enqueue_tail(177);
assert(foo.size() == 15);
assert(foo.head() == 147);
assert(foo.tail() == 177);
try{
foo.enqueue_tail(12);
}
catch ( overflow ) {
assert(true);
}
foo.clear();
cout<< " YOU PASSED MY TESTS";
return 0;
}