From d89009eeb70806f3cc088486e1a04f3be8031517 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Tue, 9 Jan 2024 23:10:05 +0000 Subject: [PATCH] test: testing records.ksy --- Makefile | 2 +- tests/test_records.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/test_records.py diff --git a/Makefile b/Makefile index b729f1e..e93eaf3 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/tests/test_records.py b/tests/test_records.py new file mode 100644 index 0000000..00641a4 --- /dev/null +++ b/tests/test_records.py @@ -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" + )