Skip to content

Commit

Permalink
Adding some test for issue kaitai-io/kaitai_struct#552.
Browse files Browse the repository at this point in the history
  • Loading branch information
ams-tschoening committed Apr 4, 2019
1 parent 5436449 commit 96ab80b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
29 changes: 29 additions & 0 deletions formats/enum_to_i_class_border_1.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# https://github.com/kaitai-io/kaitai_struct/issues/552
meta:
id: enum_to_i_class_border_1
endian: le
imports:
- enum_to_i_class_border_2

seq:
- id: pet_1
type: u4
enum: animal
- id: pet_2
type: u4
enum: animal

enums:
animal:
4: dog
7: cat
12: chicken

instances:
some_dog:
value: 4
enum: animal

checker:
pos: 0
type: enum_to_i_class_border_2(_root)
14 changes: 14 additions & 0 deletions formats/enum_to_i_class_border_2.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://github.com/kaitai-io/kaitai_struct/issues/552
meta:
id: enum_to_i_class_border_2
endian: le
imports:
- enum_to_i_class_border_1

params:
- id: parent
type: enum_to_i_class_border_1

instances:
is_dog:
value: parent.some_dog.to_i == 4
12 changes: 12 additions & 0 deletions spec/ruby/enum_to_i_class_border_1_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'enum_to_i_class_border_1'
require 'enum_to_i_class_border_2'

RSpec.describe EnumToIClassBorder1 do
it 'parses test properly' do
r = EnumToIClassBorder1.from_file('src/enum_0.bin')

expect(r.pet_1).to eq :animal_cat
expect(r.pet_2).to eq :animal_chicken
expect(r.checker.is_dog()).to eq true
end
end

0 comments on commit 96ab80b

Please sign in to comment.