-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathequal-paths-test.cpp
76 lines (64 loc) · 1.18 KB
/
equal-paths-test.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
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <cstdlib>
#include "equal-paths.h"
using namespace std;
Node* a;
Node* b;
Node* c;
Node* d;
Node* e;
Node* f;
void setNode(Node* n, int key, Node* left=NULL, Node* right=NULL)
{
n->key = key;
n->left = left;
n->right = right;
}
void test1(const char* msg)
{
setNode(a,1,NULL, NULL);
cout << msg << ": " << equalPaths(a) << endl;
}
void test2(const char* msg)
{
setNode(a,1,b,NULL);
setNode(b,2,NULL,NULL);
cout << msg << ": " << equalPaths(a) << endl;
}
void test3(const char* msg)
{
setNode(a,1,b,c);
setNode(b,2,NULL,NULL);
setNode(c,3,NULL,NULL);
cout << msg << ": " << equalPaths(a) << endl;
}
void test4(const char* msg)
{
setNode(a,1,NULL,c);
setNode(c,3,NULL,NULL);
cout << msg << ": " << equalPaths(a) << endl;
}
void test5(const char* msg)
{
setNode(a,1,b,c);
setNode(b,2,NULL,d);
setNode(c,3,NULL,NULL);
setNode(d,4,NULL,NULL);
cout << msg << ": " << equalPaths(a) << endl;
}
int main()
{
a = new Node(1);
b = new Node(2);
c = new Node(3);
d = new Node(4);
test1("Test1");
test2("Test2");
test3("Test3");
test4("Test4");
test5("Test5");
delete a;
delete b;
delete c;
delete d;
}