Skip to content

Commit

Permalink
(tests.archives)(#198) finished writing deflate test for `nexon.Pak…
Browse files Browse the repository at this point in the history
…File`
  • Loading branch information
snake-biscuits committed Sep 2, 2024
1 parent 28de818 commit ad0ddcb
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions tests/archives/nexon/test_PakFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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=""):
Expand Down

0 comments on commit ad0ddcb

Please sign in to comment.