aboutsummaryrefslogtreecommitdiff
path: root/tests/huffman/thuffmantreebuilder.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/huffman/thuffmantreebuilder.nim')
-rw-r--r--tests/huffman/thuffmantreebuilder.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/huffman/thuffmantreebuilder.nim b/tests/huffman/thuffmantreebuilder.nim
new file mode 100644
index 0000000..1045f1d
--- /dev/null
+++ b/tests/huffman/thuffmantreebuilder.nim
@@ -0,0 +1,30 @@
1# gzip-like LZSS compressor
2# Copyright (C) 2018 Pacien TRAN-GIRARD
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Affero General Public License as
6# published by the Free Software Foundation, either version 3 of the
7# License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17import unittest, streams, sequtils, tables
18import huffman/huffmantree, huffman/huffmantreebuilder
19
20suite "huffmantreebuilder":
21 let
22 stats = newCountTable(concat(repeat(1'u, 3), repeat(2'u, 1), repeat(3'u, 2)))
23 tree = huffmanBranch(
24 huffmanLeaf(1'u),
25 huffmanBranch(
26 huffmanLeaf(2'u),
27 huffmanLeaf(3'u)))
28
29 test "buildHuffmanTree":
30 check buildHuffmanTree(stats) == tree