aboutsummaryrefslogtreecommitdiff
path: root/tests/tgziplike.nim
diff options
context:
space:
mode:
authorpacien2018-12-03 18:42:23 +0100
committerpacien2018-12-03 18:42:23 +0100
commit925f8d7176c3d54d435896ec0d2eabda634bbcc8 (patch)
tree4b921a9d9d91cc0dde386d02feabed9207b51880 /tests/tgziplike.nim
parentb616e8f5773631945962d4b1256f8f2d575e0da1 (diff)
downloadgziplike-925f8d7176c3d54d435896ec0d2eabda634bbcc8.tar.gz
merge tests
Diffstat (limited to 'tests/tgziplike.nim')
-rw-r--r--tests/tgziplike.nim40
1 files changed, 0 insertions, 40 deletions
diff --git a/tests/tgziplike.nim b/tests/tgziplike.nim
deleted file mode 100644
index 836e4be..0000000
--- a/tests/tgziplike.nim
+++ /dev/null
@@ -1,40 +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, os, ospaths, osproc, times
18import gziplike
19
20suite "main":
21 const tempDir = "tmp"
22
23 proc testIdentity(input: string, intermediate = tempDir / "compressed", final = tempDir / "decompressed"): bool =
24 let compressionStartTime = getTime()
25 compress.transform(input, intermediate)
26 echo("compression done in ", getTime() - compressionStartTime)
27 echo("compression ratio: ", (intermediate.getFileSize() * 100) div input.getFileSize(), "%")
28 let decompressionStartTime = getTime()
29 decompress.transform(intermediate, final)
30 echo("decompression done in ", getTime() - decompressionStartTime)
31 startProcess("cmp", args=[input, final], options={poUsePath}).waitForExit() == 0
32
33 setup: createDir(tempDir)
34 teardown: removeDir(tempDir)
35
36 test "identity (text)":
37 check testIdentity("license.md")
38
39 test "identity (binary)":
40 check testIdentity("tests" / "tgziplike")