From b616e8f5773631945962d4b1256f8f2d575e0da1 Mon Sep 17 00:00:00 2001
From: pacien
Date: Mon, 3 Dec 2018 18:16:04 +0100
Subject: optimise lzss prefix lookup with custom hashmap
---
tests/tlzss.nim | 71 +++++++++++++++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 30 deletions(-)
(limited to 'tests')
diff --git a/tests/tlzss.nim b/tests/tlzss.nim
index ad667e5..39a89c6 100644
--- a/tests/tlzss.nim
+++ b/tests/tlzss.nim
@@ -14,25 +14,36 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-import unittest, sequtils, tables, lists
-import lzss/matchtable, lzss/lzssnode, lzss/lzsschain, lzss/lzssencoder
+import unittest, sequtils, tables, lists, algorithm
+import lzss/matchring, lzss/matchtable, lzss/lzssnode, lzss/lzsschain, lzss/lzssencoder
-suite "matchtable":
- test "matchList":
- let matchTable = initMatchTable(seq[int], int)
- check matchTable.matchList(@[0, 1, 2]).len == 0
+suite "matchring":
+ test "items (empty)":
+ var ring = initMatchRing()
+ check toSeq(ring.items).len == 0
+
+ test "addMatch, items (partial)":
+ var ring = initMatchRing()
+ let items = [0, 1, 2]
+ for i in items: ring.addMatch(i)
+ check toSeq(ring.items) == items.reversed()
+ test "addMatch, items (rolling)":
+ var ring = initMatchRing()
+ let items = toSeq(0..13)
+ for i in items: ring.addMatch(i)
+ check toSeq(ring.items) == items[^matchLimit..