Skip to content

Commit

Permalink
Merge pull request kaitai-io#17 from tschoening/ruby_calls_wrong_ctor…
Browse files Browse the repository at this point in the history
…_if_opaque_type_pull

kaitai-io/kaitai_struct_compiler kaitai-io#44: Added a test for the concrete p…
  • Loading branch information
GreyCat authored Dec 12, 2016
2 parents dc40150 + cd52717 commit b6e948d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
33 changes: 33 additions & 0 deletions formats/opaque_external_type_02_child.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://github.com/kaitai-io/kaitai_struct_compiler/issues/44
meta:
id: opaque_external_type_02_child
endian: le

seq:
- id: s1
type: strz
encoding: UTF-8
terminator: 0x7C
- id: s2
type: strz
encoding: UTF-8
terminator: 0x7C
consume: false
- id: s3
type: opaque_external_type_02_child_child

# opaque_external_type_02_child:
types:
opaque_external_type_02_child_child:
seq:
- id: s3
type: strz
encoding: UTF-8
terminator: 0x40
include: true
if: _root.some_method

# opaque_external_type_02_child:
instances:
some_method:
value: "true"
14 changes: 14 additions & 0 deletions formats/opaque_external_type_02_parent.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://github.com/kaitai-io/kaitai_struct_compiler/issues/44
meta:
id: opaque_external_type_02_parent
endian: le

seq:
- id: parent
type: parent

types:
parent:
seq:
- id: child
type: opaque_external_type_02_child
12 changes: 12 additions & 0 deletions spec/ruby/opaque_external_type_02_parent_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'opaque_external_type_02_parent'
require 'opaque_external_type_02_child'

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

expect(r.parent.child.s1).to eq('foo')
expect(r.parent.child.s2).to eq('bar')
expect(r.parent.child.s3.s3).to eq('|baz@')
end
end

0 comments on commit b6e948d

Please sign in to comment.