-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTest.cpp
60 lines (51 loc) · 1.58 KB
/
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
#include "Test.h"
void test()
{
BinaryNode* n1 = new BinaryNode((char)NULL);
BinaryNode* n2 = new BinaryNode((char)NULL);
BinaryNode* na = new BinaryNode('a');
BinaryNode* nb = new BinaryNode('b');
BinaryNode* nc = new BinaryNode('c');
n1->left = na;
n1->right = n2;
n2->left = nb;
n2->right = nc;
BinaryNode* nx1 = new BinaryNode((char)NULL);
BinaryNode* nx2 = new BinaryNode((char)NULL);
BinaryNode* nx3 = new BinaryNode((char)NULL);
BinaryNode* nx4 = new BinaryNode((char)NULL);
BinaryNode* nx5 = new BinaryNode((char)NULL);
BinaryNode* nxm = new BinaryNode('m');
BinaryNode* nxa = new BinaryNode('a');
BinaryNode* nxr = new BinaryNode('r');
BinaryNode* nxd = new BinaryNode('d');
BinaryNode* nxo = new BinaryNode('o');
BinaryNode* nxn = new BinaryNode('n');
nx1->left = nx2;
nx1->right = nx3;
nx2->left = nxm;
nx2->right = nxa;
nx3->left = nx4;
nx3->right = nx5;
nx4->left = nxr;
nx4->right = nxd;
nx5->left = nxo;
nx5->right = nxn;
map<char,string> m = getHuffmanCodes(n1);
if(getHuffmanCodes(n1)['a'] == "0"
&& getHuffmanCodes(n1)['b'] == "10"
&& getHuffmanCodes(n1)['c'] == "11"
&& getHuffmanCodes(nx1)['m'] == "00"
&& getHuffmanCodes(nx1)['a'] == "01"
&& getHuffmanCodes(nx1)['r'] == "100"
&& getHuffmanCodes(nx1)['d'] == "101"
&& getHuffmanCodes(nx1)['o'] == "110"
&& getHuffmanCodes(nx1)['n'] == "111"
)
{
cout<<"Test: Pass"<<endl;
}else
{
cout<<"Test: Fail"<<endl;
}
}