bindata 2.4.10 → 2.4.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,14 +14,14 @@ describe BinData::Registry do
14
14
  r.register('ASubClass', A)
15
15
  r.register('AnotherSubClass', B)
16
16
 
17
- r.lookup('ASubClass').must_equal A
18
- r.lookup('a_sub_class').must_equal A
19
- r.lookup('AnotherSubClass').must_equal B
20
- r.lookup('another_sub_class').must_equal B
17
+ _(r.lookup('ASubClass')).must_equal A
18
+ _(r.lookup('a_sub_class')).must_equal A
19
+ _(r.lookup('AnotherSubClass')).must_equal B
20
+ _(r.lookup('another_sub_class')).must_equal B
21
21
  end
22
22
 
23
23
  it "does not lookup unregistered names" do
24
- lambda {
24
+ _ {
25
25
  r.lookup('a_non_existent_sub_class')
26
26
  }.must_raise BinData::UnRegisteredTypeError
27
27
  end
@@ -30,7 +30,7 @@ describe BinData::Registry do
30
30
  r.register('ASubClass', A)
31
31
  r.unregister('ASubClass')
32
32
 
33
- lambda {
33
+ _ {
34
34
  r.lookup('ASubClass')
35
35
  }.must_raise BinData::UnRegisteredTypeError
36
36
  end
@@ -42,22 +42,22 @@ describe BinData::Registry do
42
42
  r.register('A', A)
43
43
  r.register('A', B)
44
44
 
45
- r.lookup('a').must_equal B
45
+ _(r.lookup('a')).must_equal B
46
46
  ensure
47
47
  $-w = w
48
48
  end
49
49
  end
50
50
 
51
51
  it "converts CamelCase to underscores" do
52
- r.underscore_name('CamelCase').must_equal 'camel_case'
52
+ _(r.underscore_name('CamelCase')).must_equal 'camel_case'
53
53
  end
54
54
 
55
55
  it "converts adjacent caps camelCase to underscores" do
56
- r.underscore_name('XYZCamelCase').must_equal 'xyz_camel_case'
56
+ _(r.underscore_name('XYZCamelCase')).must_equal 'xyz_camel_case'
57
57
  end
58
58
 
59
59
  it "ignores the outer nestings of classes" do
60
- r.underscore_name('A::B::C').must_equal 'c'
60
+ _(r.underscore_name('A::B::C')).must_equal 'c'
61
61
  end
62
62
  end
63
63
 
@@ -65,14 +65,14 @@ describe BinData::Registry, "with numerics" do
65
65
  let(:r) { BinData::RegisteredClasses }
66
66
 
67
67
  it "lookup integers with endian" do
68
- r.lookup("int24", {endian: :big}).to_s.must_equal "BinData::Int24be"
69
- r.lookup("int24", {endian: :little}).to_s.must_equal "BinData::Int24le"
70
- r.lookup("uint24", {endian: :big}).to_s.must_equal "BinData::Uint24be"
71
- r.lookup("uint24", {endian: :little}).to_s.must_equal "BinData::Uint24le"
68
+ _(r.lookup("int24", {endian: :big}).to_s).must_equal "BinData::Int24be"
69
+ _(r.lookup("int24", {endian: :little}).to_s).must_equal "BinData::Int24le"
70
+ _(r.lookup("uint24", {endian: :big}).to_s).must_equal "BinData::Uint24be"
71
+ _(r.lookup("uint24", {endian: :little}).to_s).must_equal "BinData::Uint24le"
72
72
  end
73
73
 
74
74
  it "does not lookup integers without endian" do
75
- lambda {
75
+ _ {
76
76
  r.lookup("int24")
77
77
  }.must_raise BinData::UnRegisteredTypeError
78
78
  end
@@ -81,47 +81,47 @@ describe BinData::Registry, "with numerics" do
81
81
  begin
82
82
  r.lookup("int24")
83
83
  rescue BinData::UnRegisteredTypeError => e
84
- e.message.must_equal "int24, do you need to specify endian?"
84
+ _(e.message).must_equal "int24, do you need to specify endian?"
85
85
  end
86
86
  end
87
87
 
88
88
  it "does not lookup non byte based integers" do
89
- lambda {
89
+ _ {
90
90
  r.lookup("int3")
91
91
  }.must_raise BinData::UnRegisteredTypeError
92
- lambda {
92
+ _ {
93
93
  r.lookup("int3", {endian: :big})
94
94
  }.must_raise BinData::UnRegisteredTypeError
95
- lambda {
95
+ _ {
96
96
  r.lookup("int3", {endian: :little})
97
97
  }.must_raise BinData::UnRegisteredTypeError
98
98
  end
99
99
 
100
100
  it "lookup floats with endian" do
101
- r.lookup("float", {endian: :big}).to_s.must_equal "BinData::FloatBe"
102
- r.lookup("float", {endian: :little}).to_s.must_equal "BinData::FloatLe"
103
- r.lookup("double", {endian: :big}).to_s.must_equal "BinData::DoubleBe"
104
- r.lookup("double", {endian: :little}).to_s.must_equal "BinData::DoubleLe"
101
+ _(r.lookup("float", {endian: :big}).to_s).must_equal "BinData::FloatBe"
102
+ _(r.lookup("float", {endian: :little}).to_s).must_equal "BinData::FloatLe"
103
+ _(r.lookup("double", {endian: :big}).to_s).must_equal "BinData::DoubleBe"
104
+ _(r.lookup("double", {endian: :little}).to_s).must_equal "BinData::DoubleLe"
105
105
  end
106
106
 
107
107
  it "lookup bits" do
108
- r.lookup("bit5").to_s.must_equal "BinData::Bit5"
109
- r.lookup("sbit5").to_s.must_equal "BinData::Sbit5"
110
- r.lookup("bit6le").to_s.must_equal "BinData::Bit6le"
108
+ _(r.lookup("bit5").to_s).must_equal "BinData::Bit5"
109
+ _(r.lookup("sbit5").to_s).must_equal "BinData::Sbit5"
110
+ _(r.lookup("bit6le").to_s).must_equal "BinData::Bit6le"
111
111
  end
112
112
 
113
113
  it "lookup bits by ignoring endian" do
114
- r.lookup("bit2", {endian: :big}).to_s.must_equal "BinData::Bit2"
115
- r.lookup("bit3le", {endian: :big}).to_s.must_equal "BinData::Bit3le"
116
- r.lookup("bit2", {endian: :little}).to_s.must_equal "BinData::Bit2"
117
- r.lookup("bit3le", {endian: :little}).to_s.must_equal "BinData::Bit3le"
114
+ _(r.lookup("bit2", {endian: :big}).to_s).must_equal "BinData::Bit2"
115
+ _(r.lookup("bit3le", {endian: :big}).to_s).must_equal "BinData::Bit3le"
116
+ _(r.lookup("bit2", {endian: :little}).to_s).must_equal "BinData::Bit2"
117
+ _(r.lookup("bit3le", {endian: :little}).to_s).must_equal "BinData::Bit3le"
118
118
  end
119
119
 
120
120
  it "lookup signed bits by ignoring endian" do
121
- r.lookup("sbit2", {endian: :big}).to_s.must_equal "BinData::Sbit2"
122
- r.lookup("sbit3le", {endian: :big}).to_s.must_equal "BinData::Sbit3le"
123
- r.lookup("sbit2", {endian: :little}).to_s.must_equal "BinData::Sbit2"
124
- r.lookup("sbit3le", {endian: :little}).to_s.must_equal "BinData::Sbit3le"
121
+ _(r.lookup("sbit2", {endian: :big}).to_s).must_equal "BinData::Sbit2"
122
+ _(r.lookup("sbit3le", {endian: :big}).to_s).must_equal "BinData::Sbit3le"
123
+ _(r.lookup("sbit2", {endian: :little}).to_s).must_equal "BinData::Sbit2"
124
+ _(r.lookup("sbit3le", {endian: :little}).to_s).must_equal "BinData::Sbit3le"
125
125
  end
126
126
  end
127
127
 
@@ -134,15 +134,15 @@ describe BinData::Registry, "with endian specific types" do
134
134
  end
135
135
 
136
136
  it "lookup little endian types" do
137
- r.lookup('a', {endian: :little}).must_equal A
137
+ _(r.lookup('a', {endian: :little})).must_equal A
138
138
  end
139
139
 
140
140
  it "lookup big endian types" do
141
- r.lookup('b', {endian: :big}).must_equal B
141
+ _(r.lookup('b', {endian: :big})).must_equal B
142
142
  end
143
143
 
144
144
  it "does not lookup types with non existent endian" do
145
- lambda {
145
+ _ {
146
146
  r.lookup('a', {endian: :big})
147
147
  }.must_raise BinData::UnRegisteredTypeError
148
148
  end
@@ -151,7 +151,7 @@ describe BinData::Registry, "with endian specific types" do
151
151
  r.register('c', C)
152
152
  r.register('c_le', D)
153
153
 
154
- r.lookup('c', {endian: :little}).must_equal C
154
+ _(r.lookup('c', {endian: :little})).must_equal C
155
155
  end
156
156
  end
157
157
 
@@ -164,18 +164,18 @@ describe BinData::Registry, "with search_prefix" do
164
164
  end
165
165
 
166
166
  it "lookup single search_prefix" do
167
- r.lookup('f', {search_prefix: :a}).must_equal A
167
+ _(r.lookup('f', {search_prefix: :a})).must_equal A
168
168
  end
169
169
 
170
170
  it "lookup single search_prefix with endian" do
171
- r.lookup('f', {search_prefix: :a, endian: :little}).must_equal A
171
+ _(r.lookup('f', {search_prefix: :a, endian: :little})).must_equal A
172
172
  end
173
173
 
174
174
  it "lookup multiple search_prefix" do
175
- r.lookup('f', {search_prefix: [:x, :a]}).must_equal A
175
+ _(r.lookup('f', {search_prefix: [:x, :a]})).must_equal A
176
176
  end
177
177
 
178
178
  it "lookup first match in search_prefix" do
179
- r.lookup('f', {search_prefix: [:a, :b]}).must_equal A
179
+ _(r.lookup('f', {search_prefix: [:a, :b]})).must_equal A
180
180
  end
181
181
  end
data/test/rest_test.rb CHANGED
@@ -6,23 +6,23 @@ describe BinData::Rest do
6
6
  let(:obj) { BinData::Rest.new }
7
7
 
8
8
  it "initial state" do
9
- obj.must_equal ""
9
+ _(obj).must_equal ""
10
10
  end
11
11
 
12
12
  it "reads till end of stream" do
13
13
  data = "abcdefghij"
14
- obj.read(data).must_equal data
14
+ _(obj.read(data)).must_equal data
15
15
  end
16
16
 
17
17
  it "allows setting value for completeness" do
18
18
  obj.assign("123")
19
- obj.must_equal "123"
20
- obj.to_binary_s.must_equal_binary "123"
19
+ _(obj).must_equal "123"
20
+ _(obj.to_binary_s).must_equal_binary "123"
21
21
  end
22
22
 
23
23
  it "accepts BinData::BasePrimitive parameters" do
24
24
  rest = BinData::Rest.new(assert: "abc")
25
- lambda {
25
+ _ {
26
26
  rest.read("xyz")
27
27
  }.must_raise BinData::ValidityError
28
28
  end
data/test/skip_test.rb CHANGED
@@ -6,7 +6,7 @@ describe BinData::Skip, "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::Skip.new(args) }.must_raise ArgumentError
9
+ _ { BinData::Skip.new(args) }.must_raise ArgumentError
10
10
  end
11
11
  end
12
12
  end
@@ -16,23 +16,23 @@ describe BinData::Skip, "with :length" do
16
16
  let(:io) { StringIO.new("abcdefghij") }
17
17
 
18
18
  it "initial state" do
19
- obj.must_equal ""
20
- obj.to_binary_s.must_equal_binary "\000" * 5
19
+ _(obj).must_equal ""
20
+ _(obj.to_binary_s).must_equal_binary "\000" * 5
21
21
  end
22
22
 
23
23
  it "skips bytes" do
24
24
  obj.read(io)
25
- io.pos.must_equal 5
25
+ _(io.pos).must_equal 5
26
26
  end
27
27
 
28
28
  it "has expected binary representation after setting value" do
29
29
  obj.assign("123")
30
- obj.to_binary_s.must_equal_binary "\000" * 5
30
+ _(obj.to_binary_s).must_equal_binary "\000" * 5
31
31
  end
32
32
 
33
33
  it "has expected binary representation after reading" do
34
34
  obj.read(io)
35
- obj.to_binary_s.must_equal_binary "\000" * 5
35
+ _(obj.to_binary_s).must_equal_binary "\000" * 5
36
36
  end
37
37
  end
38
38
 
@@ -46,21 +46,21 @@ describe BinData::Skip, "with :to_abs_offset" do
46
46
  fields = [ skip_obj ]
47
47
  obj = BinData::Struct.new(fields: fields)
48
48
  obj.read(io)
49
- io.pos.must_equal 5
49
+ _(io.pos).must_equal 5
50
50
  end
51
51
 
52
52
  it "reads skipping in place" do
53
53
  fields = [ [:string, :a, { read_length: 5 }], skip_obj ]
54
54
  obj = BinData::Struct.new(fields: fields)
55
55
  obj.read(io)
56
- io.pos.must_equal 5
56
+ _(io.pos).must_equal 5
57
57
  end
58
58
 
59
59
  it "does not read skipping backwards" do
60
60
  fields = [ [:string, :a, { read_length: 10 }], skip_obj ]
61
61
  obj = BinData::Struct.new(fields: fields)
62
62
 
63
- lambda {
63
+ _ {
64
64
  obj.read(io)
65
65
  }.must_raise BinData::ValidityError
66
66
  end
@@ -68,19 +68,19 @@ describe BinData::Skip, "with :to_abs_offset" do
68
68
  it "writes skipping forward" do
69
69
  fields = [ skip_obj ]
70
70
  obj = BinData::Struct.new(fields: fields)
71
- obj.to_binary_s.must_equal "\000\000\000\000\000"
71
+ _(obj.to_binary_s).must_equal "\000\000\000\000\000"
72
72
  end
73
73
 
74
74
  it "reads skipping in place" do
75
75
  fields = [ [:string, :a, { value: "abcde" }], skip_obj ]
76
76
  obj = BinData::Struct.new(fields: fields)
77
- obj.to_binary_s.must_equal "abcde"
77
+ _(obj.to_binary_s).must_equal "abcde"
78
78
  end
79
79
 
80
80
  it "does not write skipping backwards" do
81
81
  fields = [ [:string, :a, { value: "abcdefghij" }], skip_obj ]
82
82
  obj = BinData::Struct.new(fields: fields)
83
- lambda {
83
+ _ {
84
84
  obj.to_binary_s
85
85
  }.must_raise BinData::ValidityError
86
86
  end
@@ -94,7 +94,7 @@ describe BinData::Skip, "with :until_valid" do
94
94
  fields = [ [:skip, :s, { until_valid: skip_obj }] ]
95
95
  obj = BinData::Struct.new(fields: fields)
96
96
  obj.read(io)
97
- io.pos.must_equal 5
97
+ _(io.pos).must_equal 5
98
98
  end
99
99
 
100
100
  it "doesn't skip when validator doesn't assert" do
@@ -102,14 +102,14 @@ describe BinData::Skip, "with :until_valid" do
102
102
  fields = [ [:skip, :s, { until_valid: skip_obj }] ]
103
103
  obj = BinData::Struct.new(fields: fields)
104
104
  obj.read(io)
105
- io.pos.must_equal 0
105
+ _(io.pos).must_equal 0
106
106
  end
107
107
 
108
108
  it "raises EOFError when no match" do
109
109
  skip_obj = [:string, { read_length: 1, assert: "X" }]
110
110
  fields = [ [:skip, :s, { until_valid: skip_obj }] ]
111
111
  obj = BinData::Struct.new(fields: fields)
112
- lambda {
112
+ _ {
113
113
  obj.read(io)
114
114
  }.must_raise EOFError
115
115
  end
@@ -118,7 +118,7 @@ describe BinData::Skip, "with :until_valid" do
118
118
  skip_obj = [:string, { read_length: 30 }]
119
119
  fields = [ [:skip, :s, { until_valid: skip_obj }] ]
120
120
  obj = BinData::Struct.new(fields: fields)
121
- lambda {
121
+ _ {
122
122
  obj.read(io)
123
123
  }.must_raise IOError
124
124
  end
@@ -132,6 +132,6 @@ describe BinData::Skip, "with :until_valid" do
132
132
 
133
133
  it "uses block form" do
134
134
  obj = DSLSkip.read(io)
135
- obj.a.must_equal "f"
135
+ _(obj.a).must_equal "f"
136
136
  end
137
137
  end
data/test/string_test.rb CHANGED
@@ -5,17 +5,17 @@ require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
5
5
  describe BinData::String, "with mutually exclusive parameters" do
6
6
  it ":value and :initial_value" do
7
7
  params = {value: "", initial_value: ""}
8
- lambda { BinData::String.new(params) }.must_raise ArgumentError
8
+ _ { BinData::String.new(params) }.must_raise ArgumentError
9
9
  end
10
10
 
11
11
  it ":length and :read_length" do
12
12
  params = {length: 5, read_length: 5}
13
- lambda { BinData::String.new(params) }.must_raise ArgumentError
13
+ _ { BinData::String.new(params) }.must_raise ArgumentError
14
14
  end
15
15
 
16
16
  it ":value and :length" do
17
17
  params = {value: "", length: 5}
18
- lambda { BinData::String.new(params) }.must_raise ArgumentError
18
+ _ { BinData::String.new(params) }.must_raise ArgumentError
19
19
  end
20
20
  end
21
21
 
@@ -25,12 +25,12 @@ describe BinData::String, "when assigning" do
25
25
 
26
26
  it "copies data from small to large" do
27
27
  large.assign(small)
28
- large.must_equal "AAABB"
28
+ _(large).must_equal "AAABB"
29
29
  end
30
30
 
31
31
  it "copies data from large to small" do
32
32
  small.assign(large)
33
- small.must_equal "BBB"
33
+ _(small).must_equal "BBB"
34
34
  end
35
35
  end
36
36
 
@@ -38,96 +38,96 @@ describe BinData::String do
38
38
  let(:obj) { BinData::String.new("testing") }
39
39
 
40
40
  it "compares with regexp" do
41
- (/es/ =~ obj).must_equal 1
41
+ _((/es/ =~ obj)).must_equal 1
42
42
  end
43
43
 
44
44
  it "compares with regexp" do
45
- (obj =~ /es/).must_equal 1
45
+ _((obj =~ /es/)).must_equal 1
46
46
  end
47
47
  end
48
48
 
49
49
  describe BinData::String, "with :read_length" do
50
50
  let(:obj) { BinData::String.new(read_length: 5) }
51
51
 
52
- specify { obj.num_bytes.must_equal 0 }
53
- specify { obj.value.must_equal "" }
52
+ specify { _(obj.num_bytes).must_equal 0 }
53
+ specify { _(obj.value).must_equal "" }
54
54
 
55
55
  it "reads :read_length bytes" do
56
56
  obj.read("abcdefghij")
57
- obj.must_equal "abcde"
57
+ _(obj).must_equal "abcde"
58
58
  end
59
59
 
60
60
  it "remembers :read_length after value is cleared" do
61
61
  obj.assign("abc")
62
- obj.num_bytes.must_equal 3
62
+ _(obj.num_bytes).must_equal 3
63
63
  obj.clear
64
64
 
65
65
  obj.read("abcdefghij")
66
- obj.must_equal "abcde"
66
+ _(obj).must_equal "abcde"
67
67
  end
68
68
  end
69
69
 
70
70
  describe BinData::String, "with :length" do
71
71
  let(:obj) { BinData::String.new(length: 5) }
72
72
 
73
- specify { obj.num_bytes.must_equal 5 }
74
- specify { obj.value.must_equal "\0\0\0\0\0" }
73
+ specify { _(obj.num_bytes).must_equal 5 }
74
+ specify { _(obj.value).must_equal "\0\0\0\0\0" }
75
75
 
76
76
  it "retains :length after value is set" do
77
77
  obj.assign("abcdefghij")
78
- obj.num_bytes.must_equal 5
78
+ _(obj.num_bytes).must_equal 5
79
79
  end
80
80
 
81
81
  it "reads :length bytes" do
82
82
  obj.read("abcdefghij")
83
- obj.must_equal "abcde"
83
+ _(obj).must_equal "abcde"
84
84
  end
85
85
 
86
86
  it "pads values less than :length" do
87
87
  obj.assign("abc")
88
- obj.must_equal "abc\0\0"
88
+ _(obj).must_equal "abc\0\0"
89
89
  end
90
90
 
91
91
  it "accepts values exactly :length" do
92
92
  obj.assign("abcde")
93
- obj.must_equal "abcde"
93
+ _(obj).must_equal "abcde"
94
94
  end
95
95
 
96
96
  it "truncates values greater than :length" do
97
97
  obj.assign("abcdefghij")
98
- obj.must_equal "abcde"
98
+ _(obj).must_equal "abcde"
99
99
  end
100
100
  end
101
101
 
102
102
  describe BinData::String, "with :read_length and :initial_value" do
103
103
  let(:obj) { BinData::String.new(read_length: 5, initial_value: "abcdefghij") }
104
104
 
105
- specify { obj.num_bytes.must_equal 10 }
106
- specify { obj.value.must_equal "abcdefghij" }
105
+ specify { _(obj.num_bytes).must_equal 10 }
106
+ specify { _(obj.value).must_equal "abcdefghij" }
107
107
 
108
108
  it "uses :read_length for reading" do
109
109
  io = StringIO.new("ABCDEFGHIJKLMNOPQRST")
110
110
  obj.read(io)
111
- io.pos.must_equal 5
111
+ _(io.pos).must_equal 5
112
112
  end
113
113
 
114
114
  it "forgets :initial_value after reading" do
115
115
  obj.read("ABCDEFGHIJKLMNOPQRST")
116
- obj.num_bytes.must_equal 5
117
- obj.must_equal "ABCDE"
116
+ _(obj.num_bytes).must_equal 5
117
+ _(obj).must_equal "ABCDE"
118
118
  end
119
119
  end
120
120
 
121
121
  describe BinData::String, "with :read_length and :value" do
122
122
  let(:obj) { BinData::String.new(read_length: 5, value: "abcdefghij") }
123
123
 
124
- specify { obj.num_bytes.must_equal 10 }
125
- specify { obj.value.must_equal "abcdefghij" }
124
+ specify { _(obj.num_bytes).must_equal 10 }
125
+ specify { _(obj.value).must_equal "abcdefghij" }
126
126
 
127
127
  it "uses :read_length for reading" do
128
128
  io = StringIO.new("ABCDEFGHIJKLMNOPQRST")
129
129
  obj.read(io)
130
- io.pos.must_equal 5
130
+ _(io.pos).must_equal 5
131
131
  end
132
132
 
133
133
  describe "after reading" do
@@ -136,13 +136,13 @@ describe BinData::String, "with :read_length and :value" do
136
136
  end
137
137
 
138
138
  it "is not affected by :read_length after reading" do
139
- obj.num_bytes.must_equal 10
140
- obj.must_equal "abcdefghij"
139
+ _(obj.num_bytes).must_equal 10
140
+ _(obj).must_equal "abcdefghij"
141
141
  end
142
142
 
143
143
  it "returns read value while reading" do
144
144
  obj.stub :reading?, true do
145
- obj.must_equal "ABCDE"
145
+ _(obj).must_equal "ABCDE"
146
146
  end
147
147
  end
148
148
  end
@@ -151,15 +151,15 @@ end
151
151
  describe BinData::String, "with :length and :initial_value" do
152
152
  let(:obj) { BinData::String.new(length: 5, initial_value: "abcdefghij") }
153
153
 
154
- specify { obj.num_bytes.must_equal 5 }
155
- specify { obj.value.must_equal "abcde" }
154
+ specify { _(obj.num_bytes).must_equal 5 }
155
+ specify { _(obj.value).must_equal "abcde" }
156
156
 
157
157
  it "forgets :initial_value after reading" do
158
158
  io = StringIO.new("ABCDEFGHIJKLMNOPQRST")
159
159
  obj.read(io)
160
- io.pos.must_equal 5
161
- obj.num_bytes.must_equal 5
162
- obj.must_equal "ABCDE"
160
+ _(io.pos).must_equal 5
161
+ _(obj.num_bytes).must_equal 5
162
+ _(obj).must_equal "ABCDE"
163
163
  end
164
164
  end
165
165
 
@@ -167,18 +167,18 @@ describe BinData::String, "with :pad_byte" do
167
167
  it "accepts a numeric value for :pad_byte" do
168
168
  str = BinData::String.new(length: 5, pad_byte: 6)
169
169
  str.assign("abc")
170
- str.must_equal "abc\x06\x06"
170
+ _(str).must_equal "abc\x06\x06"
171
171
  end
172
172
 
173
173
  it "accepts a character for :pad_byte" do
174
174
  str = BinData::String.new(length: 5, pad_byte: "R")
175
175
  str.assign("abc")
176
- str.must_equal "abcRR"
176
+ _(str).must_equal "abcRR"
177
177
  end
178
178
 
179
179
  it "does not accept a string for :pad_byte" do
180
180
  params = {length: 5, pad_byte: "RR"}
181
- lambda { BinData::String.new(params) }.must_raise ArgumentError
181
+ _ { BinData::String.new(params) }.must_raise ArgumentError
182
182
  end
183
183
  end
184
184
 
@@ -188,8 +188,8 @@ describe BinData::String, "with :trim_padding" do
188
188
  str2 = BinData::String.new(length: 5, trim_padding: false)
189
189
  str1.assign("abc")
190
190
  str2.assign("abc")
191
- str1.must_equal "abc\0\0"
192
- str2.must_equal "abc\0\0"
191
+ _(str1).must_equal "abc\0\0"
192
+ _(str2).must_equal "abc\0\0"
193
193
  end
194
194
 
195
195
  describe "trim padding set" do
@@ -197,22 +197,22 @@ describe BinData::String, "with :trim_padding" do
197
197
 
198
198
  it "trims the value" do
199
199
  obj.assign("abcRR")
200
- obj.must_equal "abc"
200
+ _(obj).must_equal "abc"
201
201
  end
202
202
 
203
203
  it "does not affect num_bytes" do
204
204
  obj.assign("abcRR")
205
- obj.num_bytes.must_equal 5
205
+ _(obj.num_bytes).must_equal 5
206
206
  end
207
207
 
208
208
  it "trims if last char is :pad_byte" do
209
209
  obj.assign("abcRR")
210
- obj.must_equal "abc"
210
+ _(obj).must_equal "abc"
211
211
  end
212
212
 
213
213
  it "does not trim if value contains :pad_byte not at the end" do
214
214
  obj.assign("abcRRde")
215
- obj.must_equal "abcRRde"
215
+ _(obj).must_equal "abcRRde"
216
216
  end
217
217
  end
218
218
  end
@@ -223,20 +223,20 @@ describe BinData::String, "with :pad_front" do
223
223
  str2 = BinData::String.new(length: 5, pad_front: false)
224
224
  str1.assign("abc")
225
225
  str2.assign("abc")
226
- str1.must_equal "abc\0\0"
227
- str2.must_equal "abc\0\0"
226
+ _(str1).must_equal "abc\0\0"
227
+ _(str2).must_equal "abc\0\0"
228
228
  end
229
229
 
230
230
  it "pads to the front" do
231
231
  str = BinData::String.new(length: 5, pad_byte: 'R', pad_front: true)
232
232
  str.assign("abc")
233
- str.must_equal "RRabc"
233
+ _(str).must_equal "RRabc"
234
234
  end
235
235
 
236
236
  it "can alternatively be accesses by :pad_left" do
237
237
  str = BinData::String.new(length: 5, pad_byte: 'R', pad_left: true)
238
238
  str.assign("abc")
239
- str.must_equal "RRabc"
239
+ _(str).must_equal "RRabc"
240
240
  end
241
241
 
242
242
  describe "and :trim_padding" do
@@ -244,17 +244,17 @@ describe BinData::String, "with :pad_front" do
244
244
 
245
245
  it "assigns" do
246
246
  obj.assign("abc")
247
- obj.must_equal "abc"
247
+ _(obj).must_equal "abc"
248
248
  end
249
249
 
250
250
  it "has to_binary_s" do
251
251
  obj.assign("abc")
252
- obj.to_binary_s.must_equal_binary "RRabc"
252
+ _(obj.to_binary_s).must_equal_binary "RRabc"
253
253
  end
254
254
 
255
255
  it "reads" do
256
256
  obj.read "RRabc"
257
- obj.must_equal "abc"
257
+ _(obj).must_equal "abc"
258
258
  end
259
259
  end
260
260
  end
@@ -272,26 +272,26 @@ describe BinData::String, "with Ruby 1.9 encodings" do
272
272
 
273
273
  it "stores assigned values as binary" do
274
274
  obj.assign(utf8_str)
275
- obj.to_binary_s.must_equal_binary binary_str
275
+ _(obj.to_binary_s).must_equal_binary binary_str
276
276
  end
277
277
 
278
278
  it "stores read values as binary" do
279
279
  obj = UTF8String.new(read_length: binary_str.bytesize)
280
280
  obj.read(binary_str)
281
281
 
282
- obj.to_binary_s.must_equal_binary binary_str
282
+ _(obj.to_binary_s).must_equal_binary binary_str
283
283
  end
284
284
 
285
285
  it "returns values in correct encoding" do
286
286
  obj.assign(utf8_str)
287
287
 
288
- obj.snapshot.must_equal utf8_str
288
+ _(obj.snapshot).must_equal utf8_str
289
289
  end
290
290
 
291
291
  it "has correct num_bytes" do
292
292
  obj.assign(utf8_str)
293
293
 
294
- obj.num_bytes.must_equal binary_str.bytesize
294
+ _(obj.num_bytes).must_equal binary_str.bytesize
295
295
  end
296
296
  end
297
297
 
@@ -299,7 +299,7 @@ describe BinData::String, "warnings" do
299
299
  it "warns if has :asserted_value but no :length" do
300
300
  obj = BinData::String.new(asserted_value: "ABC")
301
301
  obj.must_warn "obj does not have a :read_length parameter - returning empty string" do
302
- lambda { obj.read("abcde") }.must_raise BinData::ValidityError
302
+ _ { obj.read("abcde") }.must_raise BinData::ValidityError
303
303
  end
304
304
  end
305
305