aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/tgziplike.nim30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/tgziplike.nim b/tests/tgziplike.nim
index 2b79240..836e4be 100644
--- a/tests/tgziplike.nim
+++ b/tests/tgziplike.nim
@@ -14,27 +14,27 @@
14# You should have received a copy of the GNU Affero General Public License 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/>. 15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17import unittest, os, ospaths, osproc 17import unittest, os, ospaths, osproc, times
18import gziplike 18import gziplike
19 19
20const tempDir = "tmp"
21
22suite "main": 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
23 setup: createDir(tempDir) 33 setup: createDir(tempDir)
24 teardown: removeDir(tempDir) 34 teardown: removeDir(tempDir)
25 35
26 test "identity (text)": 36 test "identity (text)":
27 let input = "license.md" 37 check testIdentity("license.md")
28 let intermediate = tempDir / "compressed"
29 let final = tempDir / "decompressed"
30 compress.transform(input, intermediate)
31 decompress.transform(intermediate, final)
32 check startProcess("cmp", args=[input, final], options={poUsePath}).waitForExit() == 0
33 38
34 test "identity (binary)": 39 test "identity (binary)":
35 let input = "tests" / "tgziplike" 40 check testIdentity("tests" / "tgziplike")
36 let intermediate = tempDir / "compressed"
37 let final = tempDir / "decompressed"
38 compress.transform(input, intermediate)
39 decompress.transform(intermediate, final)
40 check startProcess("cmp", args=[input, final], options={poUsePath}).waitForExit() == 0