bindata 2.4.12 → 2.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog.rdoc +11 -0
- data/lib/bindata/bits.rb +10 -10
- data/lib/bindata/dsl.rb +3 -3
- data/lib/bindata/int.rb +5 -7
- data/lib/bindata/params.rb +1 -1
- data/lib/bindata/version.rb +1 -1
- data/test/alignment_test.rb +8 -8
- data/test/array_test.rb +88 -88
- data/test/base_primitive_test.rb +47 -47
- data/test/base_test.rb +24 -24
- data/test/bits_test.rb +15 -15
- data/test/buffer_test.rb +22 -22
- data/test/choice_test.rb +31 -31
- data/test/count_bytes_remaining_test.rb +8 -8
- data/test/delayed_io_test.rb +37 -37
- data/test/float_test.rb +8 -8
- data/test/int_test.rb +14 -14
- data/test/io_test.rb +105 -105
- data/test/lazy_test.rb +38 -38
- data/test/offset_test.rb +8 -8
- data/test/params_test.rb +19 -19
- data/test/primitive_test.rb +26 -26
- data/test/record_test.rb +99 -99
- data/test/registry_test.rb +42 -42
- data/test/rest_test.rb +5 -5
- data/test/skip_test.rb +17 -17
- data/test/string_test.rb +56 -56
- data/test/stringz_test.rb +26 -26
- data/test/struct_test.rb +85 -85
- data/test/system_test.rb +40 -40
- data/test/test_helper.rb +2 -2
- data/test/uint8_array_test.rb +6 -6
- data/test/virtual_test.rb +7 -7
- data/test/warnings_test.rb +2 -2
- metadata +3 -3
data/test/base_primitive_test.rb
CHANGED
@@ -24,7 +24,7 @@ end
|
|
24
24
|
|
25
25
|
describe BinData::BasePrimitive do
|
26
26
|
it "is not registered" do
|
27
|
-
|
27
|
+
_ {
|
28
28
|
BinData::RegisteredClasses.lookup("BasePrimitive")
|
29
29
|
}.must_raise BinData::UnRegisteredTypeError
|
30
30
|
end
|
@@ -38,9 +38,9 @@ describe BinData::BasePrimitive, "all subclasses" do
|
|
38
38
|
let(:obj) { SubClassOfBasePrimitive.new }
|
39
39
|
|
40
40
|
it "raise errors on unimplemented methods" do
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
_ { obj.value_to_binary_string(nil) }.must_raise NotImplementedError
|
42
|
+
_ { obj.read_and_return_value(nil) }.must_raise NotImplementedError
|
43
|
+
_ { obj.sensible_default }.must_raise NotImplementedError
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -48,53 +48,53 @@ describe ExampleSingle do
|
|
48
48
|
let(:obj) { ExampleSingle.new(5) }
|
49
49
|
|
50
50
|
it "fails when assigning nil values" do
|
51
|
-
|
51
|
+
_ { obj.assign(nil) }.must_raise ArgumentError
|
52
52
|
end
|
53
53
|
|
54
54
|
it "sets and retrieves values" do
|
55
55
|
obj.assign(7)
|
56
|
-
obj.must_equal 7
|
56
|
+
_(obj).must_equal 7
|
57
57
|
end
|
58
58
|
|
59
59
|
it "sets and retrieves BinData::BasePrimitives" do
|
60
60
|
obj.assign(ExampleSingle.new(7))
|
61
|
-
obj.must_equal 7
|
61
|
+
_(obj).must_equal 7
|
62
62
|
end
|
63
63
|
|
64
64
|
it "responds to known methods" do
|
65
|
-
obj.must_respond_to :num_bytes
|
65
|
+
_(obj).must_respond_to :num_bytes
|
66
66
|
end
|
67
67
|
|
68
68
|
it "responds to known methods in #snapshot" do
|
69
|
-
obj.must_respond_to :div
|
69
|
+
_(obj).must_respond_to :div
|
70
70
|
end
|
71
71
|
|
72
72
|
it "does not respond to unknown methods in self or #snapshot" do
|
73
|
-
obj.wont_respond_to :does_not_exist
|
73
|
+
_(obj).wont_respond_to :does_not_exist
|
74
74
|
end
|
75
75
|
|
76
76
|
it "behaves as #snapshot" do
|
77
|
-
(obj + 1).must_equal 6
|
78
|
-
(1 + obj).must_equal 6
|
77
|
+
_((obj + 1)).must_equal 6
|
78
|
+
_((1 + obj)).must_equal 6
|
79
79
|
end
|
80
80
|
|
81
81
|
it "is equal to other ExampleSingle" do
|
82
|
-
obj.must_equal ExampleSingle.new(5)
|
82
|
+
_(obj).must_equal ExampleSingle.new(5)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "is equal to raw values" do
|
86
|
-
obj.must_equal 5
|
87
|
-
5.must_equal obj
|
86
|
+
_(obj).must_equal 5
|
87
|
+
_(5).must_equal obj
|
88
88
|
end
|
89
89
|
|
90
90
|
it "can be used as a hash key" do
|
91
91
|
hash = {5 => 17}
|
92
92
|
|
93
|
-
hash[obj].must_equal 17
|
93
|
+
_(hash[obj]).must_equal 17
|
94
94
|
end
|
95
95
|
|
96
96
|
it "is sortable" do
|
97
|
-
[ExampleSingle.new(5), ExampleSingle.new(3)].sort.must_equal [3, 5]
|
97
|
+
_([ExampleSingle.new(5), ExampleSingle.new(3)].sort).must_equal [3, 5]
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -103,25 +103,25 @@ describe BinData::BasePrimitive, "after initialisation" do
|
|
103
103
|
|
104
104
|
it "does not allow both :initial_value and :value" do
|
105
105
|
params = {initial_value: 1, value: 2}
|
106
|
-
|
106
|
+
_ { ExampleSingle.new(params) }.must_raise ArgumentError
|
107
107
|
end
|
108
108
|
|
109
109
|
it "initial state" do
|
110
110
|
assert obj.clear?
|
111
|
-
obj.value.must_equal 0
|
112
|
-
obj.num_bytes.must_equal 4
|
111
|
+
_(obj.value).must_equal 0
|
112
|
+
_(obj.num_bytes).must_equal 4
|
113
113
|
end
|
114
114
|
|
115
115
|
it "has symmetric IO" do
|
116
116
|
obj.assign(42)
|
117
117
|
written = obj.to_binary_s
|
118
118
|
|
119
|
-
ExampleSingle.read(written).must_equal 42
|
119
|
+
_(ExampleSingle.read(written)).must_equal 42
|
120
120
|
end
|
121
121
|
|
122
122
|
it "sets and retrieves values" do
|
123
123
|
obj.value = 5
|
124
|
-
obj.value.must_equal 5
|
124
|
+
_(obj.value).must_equal 5
|
125
125
|
end
|
126
126
|
|
127
127
|
it "is not clear after setting value" do
|
@@ -136,7 +136,7 @@ describe BinData::BasePrimitive, "after initialisation" do
|
|
136
136
|
|
137
137
|
it "returns a snapshot" do
|
138
138
|
obj.assign(5)
|
139
|
-
obj.snapshot.must_equal 5
|
139
|
+
_(obj.snapshot).must_equal 5
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -144,23 +144,23 @@ describe BinData::BasePrimitive, "with :initial_value" do
|
|
144
144
|
let(:obj) { ExampleSingle.new(initial_value: 5) }
|
145
145
|
|
146
146
|
it "initial state" do
|
147
|
-
obj.value.must_equal 5
|
147
|
+
_(obj.value).must_equal 5
|
148
148
|
end
|
149
149
|
|
150
150
|
it "forgets :initial_value after being set" do
|
151
151
|
obj.assign(17)
|
152
|
-
obj.wont_equal 5
|
152
|
+
_(obj).wont_equal 5
|
153
153
|
end
|
154
154
|
|
155
155
|
it "forgets :initial_value after reading" do
|
156
156
|
obj.read("\x11\x22\x33\x44")
|
157
|
-
obj.wont_equal 5
|
157
|
+
_(obj).wont_equal 5
|
158
158
|
end
|
159
159
|
|
160
160
|
it "remembers :initial_value after being cleared" do
|
161
161
|
obj.assign(17)
|
162
162
|
obj.clear
|
163
|
-
obj.must_equal 5
|
163
|
+
_(obj).must_equal 5
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -169,24 +169,24 @@ describe BinData::BasePrimitive, "with :value" do
|
|
169
169
|
let(:io) { ExampleSingle.io_with_value(56) }
|
170
170
|
|
171
171
|
it "initial state" do
|
172
|
-
obj.value.must_equal 5
|
172
|
+
_(obj.value).must_equal 5
|
173
173
|
end
|
174
174
|
|
175
175
|
it "changes during reading" do
|
176
176
|
obj.read(io)
|
177
177
|
obj.stub :reading?, true do
|
178
|
-
obj.must_equal 56
|
178
|
+
_(obj).must_equal 56
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
182
|
it "does not change after reading" do
|
183
183
|
obj.read(io)
|
184
|
-
obj.must_equal 5
|
184
|
+
_(obj).must_equal 5
|
185
185
|
end
|
186
186
|
|
187
187
|
it "is unaffected by assigning" do
|
188
188
|
obj.assign(17)
|
189
|
-
obj.must_equal 5
|
189
|
+
_(obj).must_equal 5
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -197,18 +197,18 @@ describe BinData::BasePrimitive, "asserting value" do
|
|
197
197
|
it "asserts sensible value" do
|
198
198
|
data = ExampleSingle.new(assert: 0)
|
199
199
|
data.assert!
|
200
|
-
data.value.must_equal 0
|
200
|
+
_(data.value).must_equal 0
|
201
201
|
end
|
202
202
|
|
203
203
|
it "succeeds when assert is correct" do
|
204
204
|
data = ExampleSingle.new(assert: 12)
|
205
205
|
data.read(io)
|
206
|
-
data.value.must_equal 12
|
206
|
+
_(data.value).must_equal 12
|
207
207
|
end
|
208
208
|
|
209
209
|
it "fails when assert is incorrect" do
|
210
210
|
data = ExampleSingle.new(assert: -> { 99 })
|
211
|
-
|
211
|
+
_ { data.read(io) }.must_raise BinData::ValidityError
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
@@ -216,12 +216,12 @@ describe BinData::BasePrimitive, "asserting value" do
|
|
216
216
|
it "succeeds when assert is true" do
|
217
217
|
data = ExampleSingle.new(assert: -> { value < 20 })
|
218
218
|
data.read(io)
|
219
|
-
data.value.must_equal 12
|
219
|
+
_(data.value).must_equal 12
|
220
220
|
end
|
221
221
|
|
222
222
|
it "fails when assert is false" do
|
223
223
|
data = ExampleSingle.new(assert: -> { value > 20 })
|
224
|
-
|
224
|
+
_ { data.read(io) }.must_raise BinData::ValidityError
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -229,12 +229,12 @@ describe BinData::BasePrimitive, "asserting value" do
|
|
229
229
|
it "succeeds when assert is correct" do
|
230
230
|
data = ExampleSingle.new(assert: 12)
|
231
231
|
data.assign(12)
|
232
|
-
data.value.must_equal 12
|
232
|
+
_(data.value).must_equal 12
|
233
233
|
end
|
234
234
|
|
235
235
|
it "fails when assert is incorrect" do
|
236
236
|
data = ExampleSingle.new(assert: 12)
|
237
|
-
|
237
|
+
_ { data.assign(99) }.must_raise BinData::ValidityError
|
238
238
|
end
|
239
239
|
end
|
240
240
|
end
|
@@ -242,19 +242,19 @@ end
|
|
242
242
|
describe BinData::BasePrimitive, ":asserted_value" do
|
243
243
|
it "has :value" do
|
244
244
|
data = ExampleSingle.new(asserted_value: -> { 12 })
|
245
|
-
data.value.must_equal 12
|
245
|
+
_(data.value).must_equal 12
|
246
246
|
end
|
247
247
|
|
248
248
|
describe "assigning with :assert" do
|
249
249
|
it "succeeds when assert is correct" do
|
250
250
|
data = ExampleSingle.new(asserted_value: -> { 12 })
|
251
251
|
data.assign(12)
|
252
|
-
data.value.must_equal 12
|
252
|
+
_(data.value).must_equal 12
|
253
253
|
end
|
254
254
|
|
255
255
|
it "fails when assert is incorrect" do
|
256
256
|
data = ExampleSingle.new(asserted_value: -> { 12 })
|
257
|
-
|
257
|
+
_ { data.assign(99) }.must_raise BinData::ValidityError
|
258
258
|
end
|
259
259
|
end
|
260
260
|
end
|
@@ -262,7 +262,7 @@ end
|
|
262
262
|
describe BinData::BasePrimitive do
|
263
263
|
it "conforms to rule 1 for returning a value" do
|
264
264
|
data = ExampleSingle.new(value: 5)
|
265
|
-
data.must_equal 5
|
265
|
+
_(data).must_equal 5
|
266
266
|
end
|
267
267
|
|
268
268
|
it "conforms to rule 2 for returning a value" do
|
@@ -271,34 +271,34 @@ describe BinData::BasePrimitive do
|
|
271
271
|
data.read(io)
|
272
272
|
|
273
273
|
data.stub :reading?, true do
|
274
|
-
data.must_equal 42
|
274
|
+
_(data).must_equal 42
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
278
|
it "conforms to rule 3 for returning a value" do
|
279
279
|
data = ExampleSingle.new(initial_value: 5)
|
280
280
|
assert data.clear?
|
281
|
-
data.must_equal 5
|
281
|
+
_(data).must_equal 5
|
282
282
|
end
|
283
283
|
|
284
284
|
it "conforms to rule 4 for returning a value" do
|
285
285
|
data = ExampleSingle.new(initial_value: 5)
|
286
286
|
data.assign(17)
|
287
287
|
refute data.clear?
|
288
|
-
data.must_equal 17
|
288
|
+
_(data).must_equal 17
|
289
289
|
end
|
290
290
|
|
291
291
|
it "conforms to rule 5 for returning a value" do
|
292
292
|
data = ExampleSingle.new
|
293
293
|
assert data.clear?
|
294
|
-
data.must_equal 0
|
294
|
+
_(data).must_equal 0
|
295
295
|
end
|
296
296
|
|
297
297
|
it "conforms to rule 6 for returning a value" do
|
298
298
|
data = ExampleSingle.new
|
299
299
|
data.assign(8)
|
300
300
|
refute data.clear?
|
301
|
-
data.must_equal 8
|
301
|
+
_(data).must_equal 8
|
302
302
|
end
|
303
303
|
end
|
304
304
|
|
data/test/base_test.rb
CHANGED
@@ -28,23 +28,23 @@ describe "BinData::Base", "framework" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "raises errors on unimplemented methods" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
_ { obj.clear? }.must_raise NotImplementedError
|
32
|
+
_ { obj.assign(nil) }.must_raise NotImplementedError
|
33
|
+
_ { obj.snapshot }.must_raise NotImplementedError
|
34
|
+
_ { obj.do_read(nil) }.must_raise NotImplementedError
|
35
|
+
_ { obj.do_write(nil) }.must_raise NotImplementedError
|
36
|
+
_ { obj.do_num_bytes }.must_raise NotImplementedError
|
37
37
|
end
|
38
38
|
|
39
39
|
it "calls initialize methods in order" do
|
40
40
|
FrameworkBase.record_calls { FrameworkBase.new }
|
41
|
-
FrameworkBase.calls.must_equal [:initialize_shared_instance, :initialize_instance]
|
41
|
+
_(FrameworkBase.calls).must_equal [:initialize_shared_instance, :initialize_instance]
|
42
42
|
end
|
43
43
|
|
44
44
|
it "does not call #initialize_shared_instance for prototypes" do
|
45
45
|
prototype = obj
|
46
46
|
FrameworkBase.record_calls { prototype.new }
|
47
|
-
FrameworkBase.calls.must_equal [:initialize_instance]
|
47
|
+
_(FrameworkBase.calls).must_equal [:initialize_instance]
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -72,9 +72,9 @@ describe BinData::Base, "ArgExtractor" do
|
|
72
72
|
data.each do |el|
|
73
73
|
args, val, param_keys, parent = *el
|
74
74
|
obj = ParamParserBase.new(*args)
|
75
|
-
obj.val.must_be_same_as val
|
76
|
-
obj.params.keys.must_equal param_keys
|
77
|
-
obj.parent.must_be_same_as parent
|
75
|
+
_(obj.val).must_be_same_as val
|
76
|
+
_(obj.params.keys).must_equal param_keys
|
77
|
+
_(obj.parent).must_be_same_as parent
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -93,36 +93,36 @@ describe BinData::Base do
|
|
93
93
|
let(:obj) { BaseStub.new }
|
94
94
|
|
95
95
|
it "::bindata_name returns lowercased name" do
|
96
|
-
BaseStub.bindata_name.must_equal "base_stub"
|
96
|
+
_(BaseStub.bindata_name).must_equal "base_stub"
|
97
97
|
end
|
98
98
|
|
99
99
|
it "::read instantiates self" do
|
100
|
-
BaseStub.read("").must_be_instance_of BaseStub
|
100
|
+
_(BaseStub.read("")).must_be_instance_of BaseStub
|
101
101
|
end
|
102
102
|
|
103
103
|
it "#read returns self" do
|
104
|
-
obj.read("").must_equal obj
|
104
|
+
_(obj.read("")).must_equal obj
|
105
105
|
end
|
106
106
|
|
107
107
|
it "#write returns self" do
|
108
|
-
obj.write("").must_equal obj
|
108
|
+
_(obj.write("")).must_equal obj
|
109
109
|
end
|
110
110
|
|
111
111
|
it "#to_hex uses #to_binary_s representation" do
|
112
112
|
obj.stub :to_binary_s, "\x01\xab\xCD" do
|
113
|
-
obj.to_hex.must_equal "01abcd"
|
113
|
+
_(obj.to_hex).must_equal "01abcd"
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
117
|
it "#inspect is forwarded to snapshot" do
|
118
118
|
obj.stub :snapshot, [1, 2, 3] do
|
119
|
-
obj.inspect.must_equal obj.snapshot.inspect
|
119
|
+
_(obj.inspect).must_equal obj.snapshot.inspect
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
it "#to_s is forwarded to snapshot" do
|
124
124
|
obj.stub :snapshot, [1, 2, 3] do
|
125
|
-
obj.to_s.must_equal obj.snapshot.to_s
|
125
|
+
_(obj.to_s).must_equal obj.snapshot.to_s
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -136,7 +136,7 @@ describe BinData::Base do
|
|
136
136
|
PP.pp(obj.snapshot, expected_io)
|
137
137
|
end
|
138
138
|
|
139
|
-
actual_io.value.must_equal expected_io.value
|
139
|
+
_(actual_io.value).must_equal expected_io.value
|
140
140
|
end
|
141
141
|
|
142
142
|
it "#write writes the same as #to_binary_s" do
|
@@ -147,7 +147,7 @@ describe BinData::Base do
|
|
147
147
|
obj = WriteToSBase.new
|
148
148
|
io = StringIO.new
|
149
149
|
obj.write(io)
|
150
|
-
io.value.must_equal obj.to_binary_s
|
150
|
+
_(io.value).must_equal obj.to_binary_s
|
151
151
|
end
|
152
152
|
|
153
153
|
it "#read is forwarded to #do_read" do
|
@@ -161,7 +161,7 @@ describe BinData::Base do
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
calls.must_equal [:clear, :do_read]
|
164
|
+
_(calls).must_equal [:clear, :do_read]
|
165
165
|
end
|
166
166
|
|
167
167
|
it "#write is forwarded to #do_write" do
|
@@ -172,18 +172,18 @@ describe BinData::Base do
|
|
172
172
|
obj.write(nil)
|
173
173
|
end
|
174
174
|
|
175
|
-
calls.must_equal [:do_write]
|
175
|
+
_(calls).must_equal [:do_write]
|
176
176
|
end
|
177
177
|
|
178
178
|
it "#num_bytes is forwarded to #do_num_bytes" do
|
179
179
|
obj.stub :do_num_bytes, 42 do
|
180
|
-
obj.num_bytes.must_equal 42
|
180
|
+
_(obj.num_bytes).must_equal 42
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
184
184
|
it "#num_bytes rounds up fractional values" do
|
185
185
|
obj.stub :do_num_bytes, 42.1 do
|
186
|
-
obj.num_bytes.must_equal 43
|
186
|
+
_(obj.num_bytes).must_equal 43
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
data/test/bits_test.rb
CHANGED
@@ -6,21 +6,21 @@ module AllBitfields
|
|
6
6
|
|
7
7
|
def test_has_a_sensible_value_of_zero
|
8
8
|
all_objects do |obj, nbits|
|
9
|
-
obj.must_equal 0
|
9
|
+
_(obj).must_equal 0
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_avoids_underflow
|
14
14
|
all_objects do |obj, nbits|
|
15
15
|
obj.assign(min_value - 1)
|
16
|
-
obj.must_equal min_value
|
16
|
+
_(obj).must_equal min_value
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_avoids_overflow
|
21
21
|
all_objects do |obj, nbits|
|
22
22
|
obj.assign(max_value + 1)
|
23
|
-
obj.must_equal max_value
|
23
|
+
_(obj).must_equal max_value
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,7 @@ module AllBitfields
|
|
28
28
|
all_objects do |obj, nbits|
|
29
29
|
some_values_within_range.each do |val|
|
30
30
|
obj.assign(val)
|
31
|
-
obj.must_equal val
|
31
|
+
_(obj).must_equal val
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -37,7 +37,7 @@ module AllBitfields
|
|
37
37
|
all_objects do |obj, nbits|
|
38
38
|
some_values_within_range.each do |val|
|
39
39
|
obj.assign(obj.new(val))
|
40
|
-
obj.must_equal val
|
40
|
+
_(obj).must_equal val
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -48,7 +48,7 @@ module AllBitfields
|
|
48
48
|
obj.assign(val)
|
49
49
|
other = obj.new
|
50
50
|
other.read(obj.to_binary_s)
|
51
|
-
other.must_equal obj
|
51
|
+
_(other).must_equal obj
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -130,7 +130,7 @@ describe "Unsigned big endian bitfields" do
|
|
130
130
|
str = [0b1000_0000].pack("C") + "\000" * (nbytes - 1)
|
131
131
|
|
132
132
|
obj.read(str)
|
133
|
-
obj.must_equal 1 << (nbits - 1)
|
133
|
+
_(obj).must_equal 1 << (nbits - 1)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
@@ -149,7 +149,7 @@ describe "Signed big endian bitfields" do
|
|
149
149
|
str = [0b0100_0000].pack("C") + "\000" * (nbytes - 1)
|
150
150
|
|
151
151
|
obj.read(str)
|
152
|
-
obj.must_equal 1 << (nbits - 2)
|
152
|
+
_(obj).must_equal 1 << (nbits - 2)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -168,7 +168,7 @@ describe "Unsigned little endian bitfields" do
|
|
168
168
|
str = [0b0000_0001].pack("C") + "\000" * (nbytes - 1)
|
169
169
|
|
170
170
|
obj.read(str)
|
171
|
-
obj.must_equal 1
|
171
|
+
_(obj).must_equal 1
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
@@ -187,7 +187,7 @@ describe "Signed little endian bitfields" do
|
|
187
187
|
str = [0b0000_0001].pack("C") + "\000" * (nbytes - 1)
|
188
188
|
|
189
189
|
obj.read(str)
|
190
|
-
obj.must_equal 1
|
190
|
+
_(obj).must_equal 1
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
@@ -199,7 +199,7 @@ describe "Bits of size 1" do
|
|
199
199
|
bit_classes.each do |bit_class|
|
200
200
|
obj = bit_class.new
|
201
201
|
obj.assign(true)
|
202
|
-
obj.must_equal 1
|
202
|
+
_(obj).must_equal 1
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
@@ -207,7 +207,7 @@ describe "Bits of size 1" do
|
|
207
207
|
bit_classes.each do |bit_class|
|
208
208
|
obj = bit_class.new
|
209
209
|
obj.assign(false)
|
210
|
-
obj.must_equal 0
|
210
|
+
_(obj).must_equal 0
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
@@ -215,16 +215,16 @@ describe "Bits of size 1" do
|
|
215
215
|
bit_classes.each do |bit_class|
|
216
216
|
obj = bit_class.new
|
217
217
|
obj.assign(nil)
|
218
|
-
obj.must_equal 0
|
218
|
+
_(obj).must_equal 0
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
222
|
it "must not be signed" do
|
223
|
-
|
223
|
+
_ {
|
224
224
|
BinData::Sbit1
|
225
225
|
}.must_raise RuntimeError
|
226
226
|
|
227
|
-
|
227
|
+
_ {
|
228
228
|
BinData::Sbit1le
|
229
229
|
}.must_raise RuntimeError
|
230
230
|
end
|