Skip to content

Commit

Permalink
test: testing records.ksy
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Jan 9, 2024
1 parent 7882790 commit d89009e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifneq (,$(wildcard /proc/sys/fs/binfmt_misc/WSLInterop))
else
JAR_PATH = /usr/share/kaitai-struct-compiler/lib/*
endif
KSY := animal fake index_option numpy pixie4e
KSY := animal fake index_option numpy pixie4e records
LIBS := $(foreach ksy,$(KSY),test_artifacts/lib$(ksy).so)

test_artifacts/lib%.so: test_artifacts/%.cpp $(BUILD)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_records.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import annotations

import sys

import numpy as np

sys.path.append("local")
import awkward_kaitai

import json
import gzip


def test_records():
reader = awkward_kaitai.Reader("test_artifacts/librecords.so")
awkward_array = reader.load("example_data/data/records.raw")

expected_array = np.array([[[[305419896]]]], dtype=np.uint32)

assert (
awkward_array.recordsA__Zlevel1.oneA__Zlevel2.twoA__Zlevel3.threeA__Zlevel4.to_numpy()
== expected_array
)
assert (
awkward_array.recordsA__Zlevel1.oneA__Zlevel2.twoA__Zlevel3.threeA__Zlevel4.typestr
== "1 * var * var * var * uint32"
)

0 comments on commit d89009e

Please sign in to comment.