1 |
Douglas Thrift |
1 |
// Unit Test |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
Douglas Thrift |
4 |
#include <iostream> |
8 |
|
|
#include <string> |
9 |
Douglas Thrift |
1 |
#include "DoublyLinkedList.hpp" |
10 |
|
|
|
11 |
Douglas Thrift |
4 |
using namespace std; |
12 |
|
|
|
13 |
Douglas Thrift |
1 |
int main(int argc, char* argv[]) |
14 |
|
|
{ |
15 |
Douglas Thrift |
6 |
cout.setf(ios_base::boolalpha); |
16 |
|
|
|
17 |
Douglas Thrift |
1 |
DoublyLinkedList<int> list; |
18 |
|
|
|
19 |
Douglas Thrift |
4 |
list.addFront(1); |
20 |
|
|
list.addBack(2); |
21 |
Douglas Thrift |
6 |
list.addFront(4); |
22 |
|
|
list.addBack(5); |
23 |
Douglas Thrift |
4 |
|
24 |
Douglas Thrift |
7 |
// 4 1 2 5 |
25 |
|
|
|
26 |
Douglas Thrift |
4 |
cout << "list.contains(1) = " << list.contains(1) << '\n' |
27 |
Douglas Thrift |
6 |
<< "list.contains(2) = " << list.contains(2) << '\n' |
28 |
|
|
<< "list.contains(3) = " << list.contains(3) << '\n' |
29 |
|
|
<< "list.contains(4) = " << list.contains(4) << '\n' |
30 |
|
|
<< "list.contains(5) = " << list.contains(5) << '\n'; |
31 |
Douglas Thrift |
4 |
|
32 |
Douglas Thrift |
6 |
list.removeFirst(2); |
33 |
|
|
|
34 |
Douglas Thrift |
7 |
// 4 1 5 |
35 |
Douglas Thrift |
6 |
|
36 |
Douglas Thrift |
7 |
cout << "list.contains(2) = " << list.contains(2) << '\n' |
37 |
|
|
<< "list.contains(5) = " << list.contains(5) << '\n'; |
38 |
|
|
|
39 |
Douglas Thrift |
8 |
for (Iterator<int> itor(list.iterator()); !itor.end(); itor++) |
40 |
Douglas Thrift |
7 |
{ |
41 |
|
|
cout << *itor << '\n'; |
42 |
|
|
} |
43 |
|
|
|
44 |
Douglas Thrift |
1 |
return 0; |
45 |
|
|
} |