From ad0ddcb3794733e1c0e781428514adbbacd4c044 Mon Sep 17 00:00:00 2001 From: snake-biscuits <36507175+snake-biscuits@users.noreply.github.com> Date: Mon, 2 Sep 2024 06:55:05 +0100 Subject: [PATCH] (tests.archives)(#198) finished writing `deflate` test for `nexon.PakFile` --- tests/archives/nexon/test_PakFile.py | 44 ++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/tests/archives/nexon/test_PakFile.py b/tests/archives/nexon/test_PakFile.py index 97609d09..7284d188 100644 --- a/tests/archives/nexon/test_PakFile.py +++ b/tests/archives/nexon/test_PakFile.py @@ -10,18 +10,33 @@ "empty": b"".join([ # just an EOCD b"CS\x05\x06", b"\x00" * 16, b"\x01", b"\x00" * 4]), # TODO: with a file - # "deflate": b"".join([ - # # LocalFile - # b"CS\x03\x04", - # ..., - # b"test.txthello~\n", - # # CentralDirectory - # b"CS\x01\x02", - # ..., - # b"test.txt" - # # EOCD - # b"CS\x05\x06", - # ...]) + "deflate": b"".join([ + # LocalFile + b"CS\x03\x04", + b"\x00\x00", # unused + b"\x99\xA0\xDC\x42", # crc32 + b"\x00\x00\x00\x00", # compressed_size + b"\x07\x00\x00\x00", # uncompressed_size + b"\x08\x00\x00\x00", # path_size + b"test.txt", # path + b"hello~\n", # data + # CentralDirectory + b"CS\x01\x02", + b"\x00\x00", # unused + b"\x99\xA0\xDC\x42", # crc32 + b"\x00\x00\x00\x00", # compressed_size + b"\x07\x00\x00\x00", # uncompressed_size + b"\x08\x00\x00\x00", # path_size + b"\x00" * 6, # unknown, header_offset + b"test.txt", # path + # EOCD + b"CS\x05\x06", + b"\x00\x00\x00\x00", # unknown + b"\x01\x00\x01\x00", # counts + b"\x24\x00\x00\x00", # sizeof_central_directories + b"\x25\x00\x00\x00", # sizeof_local_files + b"\x01\x00\x00\x00", # one + b"\x00"]) # unused # TODO: with an LZMA compressed file } @@ -30,7 +45,10 @@ def test_from_bytes(raw_pakfile: bytes): pakfile = nexon.PakFile.from_bytes(raw_pakfile) pakfile_bytes = pakfile.as_bytes() - # compare + # TODO: validate LocalFile.crc32 + # TODO: validate LocalFile matches CentralDirectory + # TODO: validate EOCD counts & sizeofs + # compare in hex view original = binary.xxd_bytes(raw_pakfile) remake = binary.xxd_bytes(pakfile_bytes) for expected, actual in zip_longest(original, remake, fillvalue=""):