-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestHuffmanTree.cpp
More file actions
57 lines (39 loc) · 1002 Bytes
/
testHuffmanTree.cpp
File metadata and controls
57 lines (39 loc) · 1002 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "catch.hpp"
#include "huffmanTree.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
TEST_CASE("Test huffmanTree class")
{
unordered_map<char,int> test;
huffmanTree htree(test);
}
TEST_CASE("Test if huffman tree creates a priority queue for a random file")
{
ifstream fin;
Encoder encode;
fin.open("./test_files/test7.txt");
if(!fin)
return;
unordered_map<char,int> test;
encode.createHistogram(fin);
test = encode.getHistogram();
map<char,int>::iterator it;
huffmanTree htree(test);
}
TEST_CASE("Test if huffman tree getRoot function returns root of tree")
{
ifstream fin;
Encoder encode;
huffmanNode *root;
fin.open("./test_files/test7.txt");
if(!fin)
return;
unordered_map<char,int> test;
encode.createHistogram(fin);
test = encode.getHistogram();
huffmanTree htree(test);
htree.buildHuffmanTree();
root = htree.getRoot();
REQUIRE((root->data == ' ' && root->frequency == 3738 && root->isInternalNode == true));
}