aboutsummaryrefslogtreecommitdiff
path: root/tests/lzsshuffman/tlzsshuffmanstats.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lzsshuffman/tlzsshuffmanstats.nim')
-rw-r--r--tests/lzsshuffman/tlzsshuffmanstats.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lzsshuffman/tlzsshuffmanstats.nim b/tests/lzsshuffman/tlzsshuffmanstats.nim
new file mode 100644
index 0000000..55eaf96
--- /dev/null
+++ b/tests/lzsshuffman/tlzsshuffmanstats.nim
@@ -0,0 +1,35 @@
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, tables, sequtils
18import lzss/lzssnode, lzss/lzsschain
19import lzsshuffman/lzsshuffmansymbol, lzsshuffman/lzsshuffmanstats
20
21suite "lzsshuffmanstats":
22 test "aggretateStats":
23 let chain = lzssChain([
24 lzssCharacter(0), lzssCharacter(1), lzssCharacter(2),
25 lzssCharacter(3), lzssCharacter(4), lzssCharacter(5),
26 lzssReference(4, 6), lzssCharacter(0), lzssCharacter(1),
27 lzssReference(3, 8), lzssCharacter(5),
28 lzssReference(3, 3), lzssCharacter(5)])
29 let (symbolTable, positionTable) = chain.aggregateStats()
30 check symbolTable == newCountTable(concat(
31 repeat(0'u16, 2), repeat(1'u16, 2), repeat(2'u16, 1), repeat(3'u16, 1), repeat(4'u16, 1), repeat(5'u16, 3),
32 repeat(endSymbol.uint16, 1),
33 repeat(257'u16, 2), repeat(258'u16, 1)))
34 check positionTable == newCountTable(concat(
35 repeat(3'u16, 1), repeat(6'u16, 1), repeat(8'u16, 1)))