Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding some test for issue #552. #50

Merged
merged 1 commit into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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