Skip to content

Commit

Permalink
Add NavRootRecursive and NavParentRecursive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
generalmimon committed Mar 15, 2024
1 parent 8372f12 commit 5941262
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
15 changes: 15 additions & 0 deletions formats/nav_parent_recursive.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Tests that `_parent` is passed to recursive invocations of the top-level type
#
# See https://github.com/kaitai-io/kaitai_struct/issues/1089
meta:
id: nav_parent_recursive
seq:
- id: value
type: u1
- id: next
type: nav_parent_recursive
if: value == 0xff
instances:
parent_value:
value: _parent.as<nav_parent_recursive>.value
if: value != 0xff
14 changes: 14 additions & 0 deletions formats/nav_root_recursive.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Tests that `_root` is passed to recursive invocations of the top-level type
#
# See https://github.com/kaitai-io/kaitai_struct/issues/1089
meta:
id: nav_root_recursive
seq:
- id: value
type: u1
- id: next
type: nav_root_recursive
if: value == 0xff
instances:
root_value:
value: _root.value
13 changes: 13 additions & 0 deletions spec/ks/nav_parent_recursive.kst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: nav_parent_recursive
data: enum_negative.bin
asserts:
- actual: value
expected: 0xff

- actual: next.value
expected: 1
- actual: next.parent_value
expected: 0xff

- actual: next.next
expected: 'null'
13 changes: 13 additions & 0 deletions spec/ks/nav_root_recursive.kst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: nav_root_recursive
data: enum_negative.bin
asserts:
- actual: value
expected: 0xff

- actual: next.value
expected: 1
- actual: next.root_value
expected: 0xff

- actual: next.next
expected: 'null'

0 comments on commit 5941262

Please sign in to comment.