aboutsummaryrefslogtreecommitdiff
path: root/tests/thuffmandecoder.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/thuffmandecoder.nim')
-rw-r--r--tests/thuffmandecoder.nim43
1 files changed, 0 insertions, 43 deletions
diff --git a/tests/thuffmandecoder.nim b/tests/thuffmandecoder.nim
deleted file mode 100644
index 9b44e9d..0000000
--- a/tests/thuffmandecoder.nim
+++ /dev/null
@@ -1,43 +0,0 @@
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
18import bitio/bitreader, bitio/bitwriter
19import huffmantree, huffmandecoder
20
21suite "huffdecoder":
22 let tree = huffmanBranch(
23 huffmanLeaf(1'u),
24 huffmanBranch(
25 huffmanLeaf(2'u),
26 huffmanLeaf(3'u)))
27
28 test "decode":
29 let stream = newStringStream()
30 defer: stream.close()
31 let bitWriter = stream.bitWriter()
32 bitWriter.writeBool(true) # 2
33 bitWriter.writeBool(false)
34 bitWriter.writeBool(false) # 1
35 bitWriter.writeBool(true) # 3
36 bitWriter.writeBool(true)
37 bitWriter.flush()
38 stream.setPosition(0)
39 let bitReader = stream.bitReader()
40 let decoder = tree.decoder()
41 check decoder.decode(bitReader) == 2'u
42 check decoder.decode(bitReader) == 1'u
43 check decoder.decode(bitReader) == 3'u