Skip to content

Commit cb77a3d

Browse files
committed
Added tests.
Minor changes in debug string generation, in order not to fail on binary inputs.
1 parent f6658f9 commit cb77a3d

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tests/testDataset"]
2+
path = tests/testDataset
3+
url = https://github.com/implode-compression-impls/implode_test_files.git

pwexplode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def explode(compressedstring):
521521
decompresseddata += decompresseddata[sourcepos:sourcepos+1]
522522

523523
# Add to debug string
524-
debug_string += decompresseddata[sourcepos:sourcepos+1].decode()
524+
debug_string += repr(decompresseddata[sourcepos:sourcepos+1])
525525

526526
# Move forward
527527
sourcepos += 1

tests/testDataset

Submodule testDataset added at 91d1ae2

tests/tests.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import unittest
4+
from collections import OrderedDict
5+
from pathlib import Path
6+
7+
from fileTestSuite.unittest import FileTestSuiteTestCaseMixin
8+
9+
dict = OrderedDict
10+
11+
thisDir = Path(__file__).resolve().absolute().parent
12+
repoRootDir = thisDir.parent
13+
14+
sys.path.insert(0, str(repoRootDir))
15+
16+
from pwexplode import explode
17+
18+
19+
class Tests(unittest.TestCase, FileTestSuiteTestCaseMixin):
20+
@property
21+
def fileTestSuiteDir(self) -> Path:
22+
return thisDir / "testDataset"
23+
24+
def _testProcessorImpl(self, challFile: Path, respFile: Path, paramsDict=None) -> None:
25+
self.assertEqual(challFile.read_bytes(), explode(respFile.read_bytes()))
26+
27+
28+
if __name__ == "__main__":
29+
unittest.main()

0 commit comments

Comments
 (0)