bindata 2.4.10 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.rdoc +39 -0
  3. data/LICENSE +25 -0
  4. data/NEWS.rdoc +5 -0
  5. data/README.md +6 -9
  6. data/bindata.gemspec +9 -4
  7. data/examples/NBT.txt +1 -1
  8. data/examples/list.rb +1 -1
  9. data/lib/bindata/alignment.rb +15 -7
  10. data/lib/bindata/array.rb +54 -54
  11. data/lib/bindata/base.rb +14 -25
  12. data/lib/bindata/base_primitive.rb +24 -20
  13. data/lib/bindata/bits.rb +15 -15
  14. data/lib/bindata/buffer.rb +89 -11
  15. data/lib/bindata/choice.rb +9 -6
  16. data/lib/bindata/count_bytes_remaining.rb +1 -1
  17. data/lib/bindata/delayed_io.rb +18 -10
  18. data/lib/bindata/dsl.rb +37 -35
  19. data/lib/bindata/float.rb +3 -3
  20. data/lib/bindata/framework.rb +8 -10
  21. data/lib/bindata/int.rb +14 -16
  22. data/lib/bindata/io.rb +276 -253
  23. data/lib/bindata/name.rb +1 -1
  24. data/lib/bindata/params.rb +9 -7
  25. data/lib/bindata/primitive.rb +3 -3
  26. data/lib/bindata/registry.rb +18 -18
  27. data/lib/bindata/rest.rb +1 -1
  28. data/lib/bindata/sanitize.rb +9 -16
  29. data/lib/bindata/section.rb +97 -0
  30. data/lib/bindata/skip.rb +140 -51
  31. data/lib/bindata/string.rb +9 -9
  32. data/lib/bindata/stringz.rb +12 -10
  33. data/lib/bindata/struct.rb +92 -68
  34. data/lib/bindata/trace.rb +35 -42
  35. data/lib/bindata/transform/brotli.rb +35 -0
  36. data/lib/bindata/transform/lz4.rb +35 -0
  37. data/lib/bindata/transform/lzma.rb +35 -0
  38. data/lib/bindata/transform/xor.rb +19 -0
  39. data/lib/bindata/transform/xz.rb +35 -0
  40. data/lib/bindata/transform/zlib.rb +33 -0
  41. data/lib/bindata/transform/zstd.rb +35 -0
  42. data/lib/bindata/uint8_array.rb +2 -2
  43. data/lib/bindata/version.rb +1 -1
  44. data/lib/bindata/virtual.rb +4 -7
  45. data/lib/bindata/warnings.rb +1 -1
  46. data/lib/bindata.rb +1 -0
  47. data/test/alignment_test.rb +8 -8
  48. data/test/array_test.rb +98 -96
  49. data/test/base_primitive_test.rb +47 -47
  50. data/test/base_test.rb +24 -24
  51. data/test/bits_test.rb +15 -15
  52. data/test/buffer_test.rb +31 -22
  53. data/test/choice_test.rb +32 -32
  54. data/test/count_bytes_remaining_test.rb +8 -8
  55. data/test/delayed_io_test.rb +91 -30
  56. data/test/float_test.rb +8 -8
  57. data/test/int_test.rb +14 -14
  58. data/test/io_test.rb +110 -302
  59. data/test/lazy_test.rb +38 -38
  60. data/test/params_test.rb +19 -19
  61. data/test/primitive_test.rb +26 -26
  62. data/test/record_test.rb +99 -99
  63. data/test/registry_test.rb +43 -43
  64. data/test/rest_test.rb +5 -5
  65. data/test/section_test.rb +111 -0
  66. data/test/skip_test.rb +71 -26
  67. data/test/string_test.rb +60 -60
  68. data/test/stringz_test.rb +34 -26
  69. data/test/struct_test.rb +167 -92
  70. data/test/system_test.rb +159 -41
  71. data/test/test_helper.rb +24 -13
  72. data/test/uint8_array_test.rb +6 -6
  73. data/test/virtual_test.rb +7 -7
  74. data/test/warnings_test.rb +14 -2
  75. metadata +19 -22
  76. data/.gitignore +0 -2
  77. data/.travis.yml +0 -15
  78. data/BSDL +0 -22
  79. data/COPYING +0 -52
  80. data/INSTALL +0 -12
  81. data/lib/bindata/offset.rb +0 -94
  82. data/test/offset_test.rb +0 -100
@@ -13,7 +13,7 @@ module BinData
13
13
  owner = method(:initialize).owner
14
14
  if owner != BinData::Base
15
15
  msg = "Don't override #initialize on #{owner}."
16
- if %w(BinData::Base BinData::BasePrimitive).include? self.class.superclass.name
16
+ if %w[BinData::Base BinData::BasePrimitive].include? self.class.superclass.name
17
17
  msg += "\nrename #initialize to #initialize_instance."
18
18
  end
19
19
  fail msg
data/lib/bindata.rb CHANGED
@@ -13,6 +13,7 @@ require 'bindata/int'
13
13
  require 'bindata/primitive'
14
14
  require 'bindata/record'
15
15
  require 'bindata/rest'
16
+ require 'bindata/section'
16
17
  require 'bindata/skip'
17
18
  require 'bindata/string'
18
19
  require 'bindata/stringz'
@@ -14,20 +14,20 @@ describe BinData::ResumeByteAlignment do
14
14
  it "resets read alignment" do
15
15
  obj.read "\x12\x34"
16
16
 
17
- obj.a.must_equal 1
18
- obj.b.must_equal 3
17
+ _(obj.a).must_equal 1
18
+ _(obj.b).must_equal 3
19
19
  end
20
20
 
21
21
  it "resets write alignment" do
22
22
  obj.assign(a: 2, b: 7)
23
23
 
24
- obj.to_binary_s.must_equal_binary "\x20\x70"
24
+ _(obj.to_binary_s).must_equal_binary "\x20\x70"
25
25
  end
26
26
  end
27
27
 
28
28
  describe BinData::BitAligned do
29
29
  it "does not apply to BinData::Primitives" do
30
- lambda {
30
+ _ {
31
31
  class BitAlignedPrimitive < BinData::Primitive
32
32
  bit_aligned
33
33
  end
@@ -47,20 +47,20 @@ describe BinData::BitAligned do
47
47
  let(:obj) { BitAlignedRecord.new }
48
48
 
49
49
  it "#num_bytes as expected" do
50
- obj.num_bytes.must_equal 3
50
+ _(obj.num_bytes).must_equal 3
51
51
  end
52
52
 
53
53
  it "has expected abs_offset" do
54
- obj.str.abs_offset.must_equal 0
54
+ _(obj.str.abs_offset).must_equal 0
55
55
  end
56
56
 
57
57
  it "reads as expected" do
58
58
  obj.read("\x56\x36\x42")
59
- obj.snapshot.must_equal({preamble: 5, str: "cd", afterward: 2})
59
+ _(obj.snapshot).must_equal({preamble: 5, str: "cd", afterward: 2})
60
60
  end
61
61
 
62
62
  it "writes as expected" do
63
63
  obj.assign(preamble: 5, str: "ab", afterward: 1)
64
- obj.to_binary_s.must_equal_binary "\x56\x16\x21"
64
+ _(obj.to_binary_s).must_equal_binary "\x56\x16\x21"
65
65
  end
66
66
  end
data/test/array_test.rb CHANGED
@@ -6,50 +6,48 @@ describe BinData::Array, "when instantiating" do
6
6
  describe "with no mandatory parameters supplied" do
7
7
  it "raises an error" do
8
8
  args = {}
9
- lambda { BinData::Array.new(args) }.must_raise ArgumentError
9
+ _ { BinData::Array.new(args) }.must_raise ArgumentError
10
10
  end
11
11
  end
12
12
 
13
13
  describe "with some but not all mandatory parameters supplied" do
14
14
  it "raises an error" do
15
15
  args = {initial_length: 3}
16
- lambda { BinData::Array.new(args) }.must_raise ArgumentError
16
+ _ { BinData::Array.new(args) }.must_raise ArgumentError
17
17
  end
18
18
  end
19
19
 
20
20
  it "warns about :length" do
21
- Kernel.must_warn ":length is not used with BinData::Array. You probably want to change this to :initial_length" do
22
- obj = BinData::Array.new(type: :uint8, length: 3)
23
- obj.read "123"
24
- end
21
+ _ {
22
+ BinData::Array.new(type: :uint8, length: 3)
23
+ }.must_warn ":length is not used with BinData::Array. You probably want to change this to :initial_length"
25
24
  end
26
25
 
27
26
  it "warns about :read_length" do
28
- Kernel.must_warn ":read_length is not used with BinData::Array. You probably want to change this to :initial_length" do
29
- obj = BinData::Array.new(type: :uint8, read_length: 3)
30
- obj.read "123"
31
- end
27
+ _ {
28
+ BinData::Array.new(type: :uint8, read_length: 3)
29
+ }.must_warn ":read_length is not used with BinData::Array. You probably want to change this to :initial_length"
32
30
  end
33
31
 
34
32
  it "fails if a given type is unknown" do
35
33
  args = {type: :does_not_exist, initial_length: 3}
36
- lambda { BinData::Array.new(args) }.must_raise BinData::UnRegisteredTypeError
34
+ _ { BinData::Array.new(args) }.must_raise BinData::UnRegisteredTypeError
37
35
  end
38
36
 
39
37
  it "fails if :initial_length is not an integer" do
40
38
  args = {type: :uint8, initial_length: "3"}
41
- lambda { BinData::Array.new(args) }.must_raise ArgumentError
39
+ _ { BinData::Array.new(args) }.must_raise ArgumentError
42
40
  end
43
41
 
44
42
  it "does not allow both :initial_length and :read_until" do
45
43
  args = {initial_length: 3, read_until: -> { false } }
46
- lambda { BinData::Array.new(args) }.must_raise ArgumentError
44
+ _ { BinData::Array.new(args) }.must_raise ArgumentError
47
45
  end
48
46
 
49
47
  it "accepts BinData::Base as :type" do
50
48
  obj = BinData::Int8.new(initial_value: 5)
51
49
  array = BinData::Array.new(type: obj, initial_length: 1)
52
- array.must_equal [5]
50
+ _(array).must_equal [5]
53
51
  end
54
52
  end
55
53
 
@@ -58,18 +56,22 @@ describe BinData::Array, "with no elements" do
58
56
 
59
57
  it "initial state" do
60
58
  assert obj.clear?
61
- obj.must_be_empty
62
- obj.length.must_equal 0
63
- obj.first.must_be_nil
64
- obj.last.must_be_nil
59
+ _(obj).must_be_empty
60
+ _(obj.length).must_equal 0
61
+ _(obj.first).must_be_nil
62
+ _(obj.last).must_be_nil
65
63
  end
66
64
 
67
65
  it "returns [] for the first n elements" do
68
- obj.first(3).must_equal []
66
+ _(obj.first(3)).must_equal []
69
67
  end
70
68
 
71
69
  it "returns [] for the last n elements" do
72
- obj.last(3).must_equal []
70
+ _(obj.last(3)).must_equal []
71
+ end
72
+
73
+ it "won't assign nil" do
74
+ _ { obj.assign(nil) }.must_raise ArgumentError
73
75
  end
74
76
  end
75
77
 
@@ -81,69 +83,69 @@ describe BinData::Array, "with several elements" do
81
83
 
82
84
  it "initial state" do
83
85
  assert obj.clear?
84
- obj.wont_be_empty
85
- obj.size.must_equal 5
86
- obj.length.must_equal 5
87
- obj.snapshot.must_equal [1, 2, 3, 4, 5]
88
- obj.inspect.must_equal "[1, 2, 3, 4, 5]"
86
+ _(obj).wont_be_empty
87
+ _(obj.size).must_equal 5
88
+ _(obj.length).must_equal 5
89
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5]
90
+ _(obj.inspect).must_equal "[1, 2, 3, 4, 5]"
89
91
  end
90
92
 
91
93
  it "coerces to ::Array if required" do
92
- [0].concat(obj).must_equal [0, 1, 2, 3, 4, 5]
94
+ _([0].concat(obj)).must_equal [0, 1, 2, 3, 4, 5]
93
95
  end
94
96
 
95
97
  it "uses methods from Enumerable" do
96
- obj.select { |x| (x % 2) == 0 }.must_equal [2, 4]
98
+ _(obj.select { |x| (x % 2) == 0 }).must_equal [2, 4]
97
99
  end
98
100
 
99
101
  it "assigns primitive values" do
100
102
  obj.assign([4, 5, 6])
101
- obj.must_equal [4, 5, 6]
103
+ _(obj).must_equal [4, 5, 6]
102
104
  end
103
105
 
104
106
  it "assigns bindata objects" do
105
107
  obj.assign([BinData::Uint32le.new(4), BinData::Uint32le.new(5), BinData::Uint32le.new(6)])
106
- obj.must_equal [4, 5, 6]
108
+ _(obj).must_equal [4, 5, 6]
107
109
  end
108
110
 
109
111
  it "assigns a bindata array" do
110
112
  array = BinData::Array.new([4, 5, 6], type: :uint32le)
111
113
  obj.assign(array)
112
- obj.must_equal [4, 5, 6]
114
+ _(obj).must_equal [4, 5, 6]
113
115
  end
114
116
 
115
117
  it "returns the first element" do
116
- obj.first.must_equal 1
118
+ _(obj.first).must_equal 1
117
119
  end
118
120
 
119
121
  it "returns the first n elements" do
120
- obj[0...3].must_equal [1, 2, 3]
121
- obj.first(3).must_equal [1, 2, 3]
122
- obj.first(99).must_equal [1, 2, 3, 4, 5]
122
+ _(obj[0...3]).must_equal [1, 2, 3]
123
+ _(obj.first(3)).must_equal [1, 2, 3]
124
+ _(obj.first(99)).must_equal [1, 2, 3, 4, 5]
123
125
  end
124
126
 
125
127
  it "returns the last element" do
126
- obj.last.must_equal 5
127
- obj[-1].must_equal 5
128
+ _(obj.last).must_equal 5
129
+ _(obj[-1]).must_equal 5
128
130
  end
129
131
 
130
132
  it "returns the last n elements" do
131
- obj.last(3).must_equal [3, 4, 5]
132
- obj.last(99).must_equal [1, 2, 3, 4, 5]
133
+ _(obj.last(3)).must_equal [3, 4, 5]
134
+ _(obj.last(99)).must_equal [1, 2, 3, 4, 5]
133
135
 
134
- obj[-3, 100].must_equal [3, 4, 5]
136
+ _(obj[-3, 100]).must_equal [3, 4, 5]
135
137
  end
136
138
 
137
139
  it "clears all" do
138
140
  obj[1] = 8
139
141
  obj.clear
140
- obj.must_equal [1, 2, 3, 4, 5]
142
+ _(obj).must_equal [1, 2, 3, 4, 5]
141
143
  end
142
144
 
143
145
  it "clears a single element" do
144
146
  obj[1] = 8
145
147
  obj[1].clear
146
- obj[1].must_equal 2
148
+ _(obj[1]).must_equal 2
147
149
  end
148
150
 
149
151
  it "is clear if all elements are clear" do
@@ -160,7 +162,7 @@ describe BinData::Array, "with several elements" do
160
162
 
161
163
  it "directly accesses elements" do
162
164
  obj[1] = 8
163
- obj[1].must_equal 8
165
+ _(obj[1]).must_equal 8
164
166
  end
165
167
 
166
168
  it "symmetrically reads and writes" do
@@ -168,34 +170,34 @@ describe BinData::Array, "with several elements" do
168
170
  str = obj.to_binary_s
169
171
 
170
172
  obj.clear
171
- obj[1].must_equal 2
173
+ _(obj[1]).must_equal 2
172
174
 
173
175
  obj.read(str)
174
- obj[1].must_equal 8
176
+ _(obj[1]).must_equal 8
175
177
  end
176
178
 
177
179
  it "identifies index of elements" do
178
- obj.index(3).must_equal 2
180
+ _(obj.index(3)).must_equal 2
179
181
  end
180
182
 
181
183
  it "returns nil for index of non existent element" do
182
- obj.index(42).must_be_nil
184
+ _(obj.index(42)).must_be_nil
183
185
  end
184
186
 
185
187
  it "has correct debug name" do
186
- obj[2].debug_name.must_equal "obj[2]"
188
+ _(obj[2].debug_name).must_equal "obj[2]"
187
189
  end
188
190
 
189
191
  it "has correct offset" do
190
- obj[2].rel_offset.must_equal 2 * 4
192
+ _(obj[2].rel_offset).must_equal 2 * 4
191
193
  end
192
194
 
193
195
  it "has correct num_bytes" do
194
- obj.num_bytes.must_equal 5 * 4
196
+ _(obj.num_bytes).must_equal 5 * 4
195
197
  end
196
198
 
197
199
  it "has correct num_bytes for individual elements" do
198
- obj[0].num_bytes.must_equal 4
200
+ _(obj[0].num_bytes).must_equal 4
199
201
  end
200
202
  end
201
203
 
@@ -209,67 +211,67 @@ describe BinData::Array, "when accessing elements" do
209
211
 
210
212
  it "inserts with positive indexes" do
211
213
  obj.insert(2, 30, 40)
212
- obj.snapshot.must_equal [1, 2, 30, 40, 3, 4, 5]
214
+ _(obj.snapshot).must_equal [1, 2, 30, 40, 3, 4, 5]
213
215
  end
214
216
 
215
217
  it "inserts with negative indexes" do
216
218
  obj.insert(-2, 30, 40)
217
- obj.snapshot.must_equal [1, 2, 3, 4, 30, 40, 5]
219
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 30, 40, 5]
218
220
  end
219
221
 
220
222
  it "pushes" do
221
223
  obj.push(30, 40)
222
- obj.snapshot.must_equal [1, 2, 3, 4, 5, 30, 40]
224
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5, 30, 40]
223
225
  end
224
226
 
225
227
  it "concats" do
226
228
  obj.concat([30, 40])
227
- obj.snapshot.must_equal [1, 2, 3, 4, 5, 30, 40]
229
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5, 30, 40]
228
230
  end
229
231
 
230
232
  it "unshifts" do
231
233
  obj.unshift(30, 40)
232
- obj.snapshot.must_equal [30, 40, 1, 2, 3, 4, 5]
234
+ _(obj.snapshot).must_equal [30, 40, 1, 2, 3, 4, 5]
233
235
  end
234
236
 
235
237
  it "automatically extends on [index]" do
236
- obj[9].must_equal 10
237
- obj.snapshot.must_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
238
+ _(obj[9]).must_equal 10
239
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
238
240
  end
239
241
 
240
242
  it "automatically extends on []=" do
241
243
  obj[9] = 30
242
- obj.snapshot.must_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 30]
244
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 30]
243
245
  end
244
246
 
245
247
  it "automatically extends on insert" do
246
248
  obj.insert(7, 30, 40)
247
- obj.snapshot.must_equal [1, 2, 3, 4, 5, 6, 7, 30, 40]
249
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5, 6, 7, 30, 40]
248
250
  end
249
251
 
250
252
  it "does not extend on at" do
251
- obj.at(9).must_be_nil
252
- obj.length.must_equal 5
253
+ _(obj.at(9)).must_be_nil
254
+ _(obj.length).must_equal 5
253
255
  end
254
256
 
255
257
  it "does not extend on [start, length]" do
256
- obj[9, 2].must_be_nil
257
- obj.length.must_equal 5
258
+ _(obj[9, 2]).must_be_nil
259
+ _(obj.length).must_equal 5
258
260
  end
259
261
 
260
262
  it "does not extend on [range]" do
261
- obj[9 .. 10].must_be_nil
262
- obj.length.must_equal 5
263
+ _(obj[9 .. 10]).must_be_nil
264
+ _(obj.length).must_equal 5
263
265
  end
264
266
 
265
267
  it "raises error on bad input to []" do
266
- lambda { obj["a"] }.must_raise TypeError
267
- lambda { obj[1, "a"] }.must_raise TypeError
268
+ _ { obj["a"] }.must_raise TypeError
269
+ _ { obj[1, "a"] }.must_raise TypeError
268
270
  end
269
271
 
270
272
  it "is unaffected by self assignment" do
271
273
  obj.assign(obj)
272
- obj.snapshot.must_equal [1, 2, 3, 4, 5]
274
+ _(obj.snapshot).must_equal [1, 2, 3, 4, 5]
273
275
  end
274
276
  end
275
277
 
@@ -281,7 +283,7 @@ describe BinData::Array, "with :read_until" do
281
283
  obj = BinData::Array.new(type: :int8, read_until: read_until)
282
284
 
283
285
  obj.read "\x01\x02\x03\x04\x05\x06\x07\x08"
284
- obj.must_equal [1, 2, 3, 4, 5]
286
+ _(obj).must_equal [1, 2, 3, 4, 5]
285
287
  end
286
288
  end
287
289
 
@@ -291,7 +293,7 @@ describe BinData::Array, "with :read_until" do
291
293
  obj = BinData::Array.new(type: :int8, read_until: read_until)
292
294
 
293
295
  obj.read "\x01\x02\x03\x04\x05\x06\x07\x08"
294
- obj.must_equal [1, 2, 3, 4, 5, 6, 7]
296
+ _(obj).must_equal [1, 2, 3, 4, 5, 6, 7]
295
297
  end
296
298
  end
297
299
 
@@ -300,20 +302,20 @@ describe BinData::Array, "with :read_until" do
300
302
  obj = BinData::Array.new(type: :int8, read_until: :eof)
301
303
 
302
304
  obj.read "\x01\x02\x03"
303
- obj.must_equal [1, 2, 3]
305
+ _(obj).must_equal [1, 2, 3]
304
306
  end
305
307
 
306
308
  it "reads records until eof, ignoring partial records" do
307
309
  obj = BinData::Array.new(type: :int16be, read_until: :eof)
308
310
 
309
311
  obj.read "\x00\x01\x00\x02\x03"
310
- obj.must_equal [1, 2]
312
+ _(obj).must_equal [1, 2]
311
313
  end
312
314
 
313
315
  it "reports exceptions" do
314
316
  array_type = [:string, {read_length: -> { unknown_variable }}]
315
317
  obj = BinData::Array.new(type: array_type, read_until: :eof)
316
- lambda { obj.read "\x00\x01\x00\x02\x03" }.must_raise NoMethodError
318
+ _ { obj.read "\x00\x01\x00\x02\x03" }.must_raise NoMethodError
317
319
  end
318
320
  end
319
321
  end
@@ -327,12 +329,12 @@ describe BinData::Array, "nested within an Array" do
327
329
  }
328
330
 
329
331
  it "#snapshot" do
330
- obj.snapshot.must_equal [ [0], [0, 1], [0, 1, 2] ]
332
+ _(obj.snapshot).must_equal [ [0], [0, 1], [0, 1, 2] ]
331
333
  end
332
334
 
333
335
  it "maintains structure when reading" do
334
336
  obj.read "\x04\x05\x06\x07\x08\x09"
335
- obj.must_equal [ [4], [5, 6], [7, 8, 9] ]
337
+ _(obj).must_equal [ [4], [5, 6], [7, 8, 9] ]
336
338
  end
337
339
  end
338
340
 
@@ -346,12 +348,12 @@ describe BinData::Array, "subclassed" do
346
348
 
347
349
  it "forwards parameters" do
348
350
  obj = IntArray.new(initial_length: 7)
349
- obj.length.must_equal 7
351
+ _(obj.length).must_equal 7
350
352
  end
351
353
 
352
354
  it "overrides default parameters" do
353
355
  obj = IntArray.new(initial_length: 3, initial_element_value: 5)
354
- obj.to_binary_s.must_equal_binary "\x00\x05\x00\x05\x00\x05"
356
+ _(obj.to_binary_s).must_equal_binary "\x00\x05\x00\x05\x00\x05"
355
357
  end
356
358
  end
357
359
 
@@ -361,35 +363,35 @@ describe BinData::Array, "of bits" do
361
363
  it "reads" do
362
364
  str = [0b0001_0100, 0b1000_1000].pack("CC")
363
365
  obj.read(str)
364
- obj[0].must_equal 0
365
- obj[1].must_equal 0
366
- obj[2].must_equal 0
367
- obj[3].must_equal 1
368
- obj[4].must_equal 0
369
- obj[5].must_equal 1
370
- obj[6].must_equal 0
371
- obj[7].must_equal 0
372
- obj[8].must_equal 1
373
- obj[9].must_equal 0
374
- obj[10].must_equal 0
375
- obj[11].must_equal 0
376
- obj[12].must_equal 1
377
- obj[13].must_equal 0
378
- obj[14].must_equal 0
366
+ _(obj[0]).must_equal 0
367
+ _(obj[1]).must_equal 0
368
+ _(obj[2]).must_equal 0
369
+ _(obj[3]).must_equal 1
370
+ _(obj[4]).must_equal 0
371
+ _(obj[5]).must_equal 1
372
+ _(obj[6]).must_equal 0
373
+ _(obj[7]).must_equal 0
374
+ _(obj[8]).must_equal 1
375
+ _(obj[9]).must_equal 0
376
+ _(obj[10]).must_equal 0
377
+ _(obj[11]).must_equal 0
378
+ _(obj[12]).must_equal 1
379
+ _(obj[13]).must_equal 0
380
+ _(obj[14]).must_equal 0
379
381
  end
380
382
 
381
383
  it "writes" do
382
384
  obj[3] = 1
383
- obj.to_binary_s.must_equal_binary [0b0001_0000, 0b0000_0000].pack("CC")
385
+ _(obj.to_binary_s).must_equal_binary [0b0001_0000, 0b0000_0000].pack("CC")
384
386
  end
385
387
 
386
388
  it "returns num_bytes" do
387
- obj.num_bytes.must_equal 2
389
+ _(obj.num_bytes).must_equal 2
388
390
  end
389
391
 
390
392
  it "has correct offset" do
391
- obj[7].rel_offset.must_equal 0
392
- obj[8].rel_offset.must_equal 1
393
+ _(obj[7].rel_offset).must_equal 0
394
+ _(obj[8].rel_offset).must_equal 1
393
395
  end
394
396
  end
395
397