slow_blink 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/slow_blink/ext_schema_parser/lexer.c +2793 -839
- data/ext/slow_blink/ext_schema_parser/lexer.h +14 -137
- data/ext/slow_blink/ext_schema_parser/parser.c +616 -670
- data/ext/slow_blink/ext_schema_parser/parser.h +6 -4
- data/ext/slow_blink/message/ext_compact_encoder/blink_compact.c +642 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_compact.h +411 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_debug.h +46 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_stream.c +314 -0
- data/ext/slow_blink/message/ext_compact_encoder/blink_stream.h +185 -0
- data/ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c +382 -269
- data/lib/slow_blink/definition.rb +18 -53
- data/lib/slow_blink/dynamic_group.rb +8 -0
- data/lib/slow_blink/enum.rb +101 -0
- data/lib/slow_blink/field.rb +63 -33
- data/lib/slow_blink/generate_c/model.rb +89 -0
- data/lib/slow_blink/group.rb +119 -100
- data/lib/slow_blink/message/binary.rb +3 -4
- data/lib/slow_blink/message/boolean.rb +3 -4
- data/lib/slow_blink/message/date.rb +3 -4
- data/lib/slow_blink/message/decimal.rb +3 -5
- data/lib/slow_blink/message/{enumeration.rb → enum.rb} +17 -17
- data/lib/slow_blink/message/field.rb +77 -27
- data/lib/slow_blink/message/fixed.rb +5 -21
- data/lib/slow_blink/message/floating_point.rb +3 -4
- data/lib/slow_blink/message/group.rb +90 -161
- data/lib/slow_blink/message/integer.rb +24 -32
- data/lib/slow_blink/message/model.rb +50 -110
- data/lib/slow_blink/message/string.rb +3 -4
- data/lib/slow_blink/message/time.rb +5 -5
- data/lib/slow_blink/message/time_of_day.rb +5 -12
- data/lib/slow_blink/ref.rb +22 -71
- data/lib/slow_blink/schema.rb +64 -85
- data/lib/slow_blink/schema_buffer.rb +1 -4
- data/lib/slow_blink/static_group.rb +37 -0
- data/lib/slow_blink/string.rb +4 -5
- data/lib/slow_blink/sym.rb +8 -28
- data/lib/slow_blink/type.rb +10 -19
- data/lib/slow_blink/version.rb +1 -1
- data/lib/slow_blink.rb +1 -0
- data/test/tc_compact_encoder.rb +114 -147
- data/test/tc_inputs.rb +2 -4
- data/test/tc_model_string.rb +29 -0
- data/test/tc_schema_new.rb +212 -0
- metadata +17 -26
- data/ext/slow_blink/ext_schema_parser/common.h +0 -27
- data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.c +0 -258
- data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.h +0 -92
- data/lib/slow_blink/annotatable.rb +0 -48
- data/lib/slow_blink/annotation.rb +0 -47
- data/lib/slow_blink/enumeration.rb +0 -90
- data/lib/slow_blink/incremental_annotation.rb +0 -151
- data/lib/slow_blink/log.rb +0 -51
- data/lib/slow_blink/message/sequence.rb +0 -98
- data/lib/slow_blink/name_with_id.rb +0 -49
- data/lib/slow_blink/namespace.rb +0 -143
- data/lib/slow_blink/sequence.rb +0 -57
- data/test/tc_field.rb +0 -94
- data/test/tc_group.rb +0 -114
- data/test/tc_incr_annote.rb +0 -22
- data/test/tc_namespace.rb +0 -8
- data/test/tc_types.rb +0 -218
@@ -0,0 +1,37 @@
|
|
1
|
+
module SlowBlink
|
2
|
+
class StaticGroup < Type
|
3
|
+
|
4
|
+
# @return [String]
|
5
|
+
def name
|
6
|
+
@group.name
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [Integer,nil]
|
10
|
+
def id
|
11
|
+
@group.id
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Array<Field>]
|
15
|
+
def fields
|
16
|
+
@group.fields
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Group]
|
20
|
+
def superGroup
|
21
|
+
@group.superGroup
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Array<Groups>]
|
25
|
+
def ancestors
|
26
|
+
@group.ancestors
|
27
|
+
end
|
28
|
+
|
29
|
+
# @private
|
30
|
+
def initialize(attr)
|
31
|
+
super(attr)
|
32
|
+
@group = attr[:group]
|
33
|
+
@table = attr[:table]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/slow_blink/string.rb
CHANGED
@@ -29,11 +29,10 @@ module SlowBlink
|
|
29
29
|
# @return [nil] no maximum size
|
30
30
|
attr_reader :size
|
31
31
|
|
32
|
-
# @
|
33
|
-
|
34
|
-
|
35
|
-
@size = size
|
36
|
-
super(location)
|
32
|
+
# @private
|
33
|
+
def initialize(attr)
|
34
|
+
super(attr)
|
35
|
+
@size = attr[:size]
|
37
36
|
end
|
38
37
|
|
39
38
|
end
|
data/lib/slow_blink/sym.rb
CHANGED
@@ -22,8 +22,6 @@
|
|
22
22
|
module SlowBlink
|
23
23
|
class Sym
|
24
24
|
|
25
|
-
include Annotatable
|
26
|
-
|
27
25
|
# @macro location
|
28
26
|
attr_reader :location
|
29
27
|
|
@@ -31,32 +29,14 @@ module SlowBlink
|
|
31
29
|
attr_reader :name
|
32
30
|
|
33
31
|
# @return [Integer]
|
34
|
-
attr_reader :
|
35
|
-
|
36
|
-
# @
|
37
|
-
def
|
38
|
-
@
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# @param val [nil,Integer] explicit value
|
43
|
-
# @param location [String]
|
44
|
-
def initialize(name, val, location)
|
45
|
-
@name = name
|
46
|
-
@val = val
|
47
|
-
@annotes = {}
|
48
|
-
@location = location
|
49
|
-
@implicit = (val ? false : true)
|
50
|
-
end
|
51
|
-
|
52
|
-
# @api private
|
53
|
-
# Resolve references, enforce constraints, and detect cycles
|
54
|
-
#
|
55
|
-
# @param schema [Schema] schema this definition belongs to
|
56
|
-
# @param stack [nil, Array] objects that depend on this object
|
57
|
-
# @return [true,false] linked?
|
58
|
-
def link(schema, stack=[])
|
59
|
-
@schema = schema
|
32
|
+
attr_reader :value
|
33
|
+
|
34
|
+
# @private
|
35
|
+
def initialize(attr)
|
36
|
+
@name = attr[:name].to_s
|
37
|
+
@value = attr[:value]
|
38
|
+
@location = attr[:loc]
|
39
|
+
@implicit = attr[:implicit]
|
60
40
|
end
|
61
41
|
|
62
42
|
end
|
data/lib/slow_blink/type.rb
CHANGED
@@ -24,34 +24,25 @@ module SlowBlink
|
|
24
24
|
|
25
25
|
class Type
|
26
26
|
|
27
|
-
include Annotatable
|
28
|
-
|
29
27
|
# @macro location
|
30
28
|
attr_reader :location
|
31
29
|
|
30
|
+
# @return [true] this type is sequence (repeating) type
|
31
|
+
def sequence?
|
32
|
+
@sequence
|
33
|
+
end
|
34
|
+
|
32
35
|
def self.===(other)
|
33
36
|
self == other
|
34
37
|
end
|
35
38
|
|
36
|
-
# @
|
37
|
-
def initialize(
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
39
|
+
# @private
|
40
|
+
def initialize(attr)
|
41
|
+
@location = attr[:loc].freeze
|
42
|
+
@sequence = attr[:sequence]
|
43
|
+
@ns = attr[:ns].freeze
|
41
44
|
end
|
42
45
|
|
43
|
-
# @api private
|
44
|
-
#
|
45
|
-
# Resolve references, enforce constraints, and detect cycles
|
46
|
-
#
|
47
|
-
# @param schema [Schema] schema this definition belongs to
|
48
|
-
# @param ns [Namespace] namespace this definition belongs to
|
49
|
-
# @param stack [nil, Array] objects that depend on this object
|
50
|
-
# @return [true,false] linked?
|
51
|
-
def link(schema, ns, stack=[])
|
52
|
-
@schema = schema
|
53
|
-
end
|
54
|
-
|
55
46
|
end
|
56
47
|
|
57
48
|
end
|
data/lib/slow_blink/version.rb
CHANGED
data/lib/slow_blink.rb
CHANGED
data/test/tc_compact_encoder.rb
CHANGED
@@ -7,369 +7,336 @@ class TestCompactEncoder < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def test_putU8
|
9
9
|
input = 0x7f
|
10
|
-
output =
|
11
|
-
assert_equal("\x7f", output)
|
10
|
+
output = String.new.putU8(input)
|
11
|
+
assert_equal("\x7f".force_encoding("ASCII-8BIT"), output)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_putU8_big
|
15
15
|
input = 0x80
|
16
|
-
output =
|
17
|
-
assert_equal("\x80\x02", output)
|
16
|
+
output = String.new.putU8(input)
|
17
|
+
assert_equal("\x80\x02".force_encoding("ASCII-8BIT"), output)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_putU8_tooBig
|
21
21
|
input = 0x100
|
22
22
|
assert_raise RangeError do
|
23
|
-
|
23
|
+
String.new.putU8(input)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_putU8_null
|
28
28
|
input = nil
|
29
|
-
output =
|
30
|
-
assert_equal("\xc0", output)
|
29
|
+
output = String.new.putU8(input)
|
30
|
+
assert_equal("\xc0".force_encoding("ASCII-8BIT"), output)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_putU16_small
|
34
34
|
input = 0xff
|
35
|
-
output =
|
36
|
-
assert_equal("\xbf\x03", output)
|
35
|
+
output = String.new.putU16(input)
|
36
|
+
assert_equal("\xbf\x03".force_encoding("ASCII-8BIT"), output)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_putU16
|
40
40
|
input = 0xffff
|
41
|
-
output =
|
42
|
-
assert_equal("\xC2\xff\xff", output)
|
41
|
+
output = String.new.putU16(input)
|
42
|
+
assert_equal("\xC2\xff\xff".force_encoding("ASCII-8BIT"), output)
|
43
43
|
end
|
44
44
|
|
45
45
|
# Blink Specification 3.1
|
46
46
|
def test_putU8_64unsigned
|
47
47
|
input = 64
|
48
|
-
output =
|
49
|
-
assert_equal("\x40", output)
|
48
|
+
output = String.new.putU8(input)
|
49
|
+
assert_equal("\x40".force_encoding("ASCII-8BIT"), output)
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_putU16_16383
|
53
53
|
input = 16383
|
54
|
-
output =
|
55
|
-
assert_equal("\xBf\xff", output)
|
54
|
+
output = String.new.putU16(input)
|
55
|
+
assert_equal("\xBf\xff".force_encoding("ASCII-8BIT"), output)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_putI16_16383
|
59
59
|
input = 16383
|
60
|
-
output =
|
61
|
-
assert_equal("\xC2\xff\x3f", output)
|
60
|
+
output = String.new.putI16(input)
|
61
|
+
assert_equal("\xC2\xff\x3f".force_encoding("ASCII-8BIT"), output)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Blink Specification 3.1
|
65
65
|
def test_putI8_64signed
|
66
66
|
input = 64
|
67
|
-
output =
|
68
|
-
assert_equal("\x80\x01", output)
|
67
|
+
output = String.new.putI8(input)
|
68
|
+
assert_equal("\x80\x01".force_encoding("ASCII-8BIT"), output)
|
69
69
|
end
|
70
70
|
|
71
71
|
# Blink Specification 3.1
|
72
72
|
def test_putU16_4711unsigned
|
73
73
|
input = 4711
|
74
|
-
output =
|
75
|
-
assert_equal("\xa7\x49", output)
|
74
|
+
output = String.new.putU16(input)
|
75
|
+
assert_equal("\xa7\x49".force_encoding("ASCII-8BIT"), output)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Blink Specification 3.1
|
79
79
|
def test_putU32_4294967295unsigned
|
80
80
|
input = 4294967295
|
81
|
-
output =
|
82
|
-
assert_equal("\xc4\xff\xff\xff\xff", output)
|
81
|
+
output = String.new.putU32(input)
|
82
|
+
assert_equal("\xc4\xff\xff\xff\xff".force_encoding("ASCII-8BIT"), output)
|
83
83
|
end
|
84
84
|
|
85
85
|
# Blink Specification 3.1
|
86
86
|
def test_putI8_minus64
|
87
87
|
input = -64
|
88
|
-
output =
|
89
|
-
assert_equal("\x40", output)
|
88
|
+
output = String.new.putI8(input)
|
89
|
+
assert_equal("\x40".force_encoding("ASCII-8BIT"), output)
|
90
90
|
end
|
91
91
|
|
92
92
|
# Blink Specification 3.1
|
93
93
|
def test_putI16_minus4711
|
94
94
|
input = -4711
|
95
|
-
output =
|
96
|
-
assert_equal("\x99\xb6", output)
|
95
|
+
output = String.new.putI16(input)
|
96
|
+
assert_equal("\x99\xb6".force_encoding("ASCII-8BIT"), output)
|
97
97
|
end
|
98
98
|
|
99
99
|
# Blink Specification 3.1
|
100
100
|
def test_putI32_minus2147483648
|
101
101
|
input = -2147483648
|
102
|
-
output =
|
103
|
-
assert_equal("\xc4\x00\x00\x00\x80", output)
|
102
|
+
output = String.new.putI32(input)
|
103
|
+
assert_equal("\xc4\x00\x00\x00\x80".force_encoding("ASCII-8BIT"), output)
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_putFixed
|
107
107
|
input = "hello world"
|
108
|
-
output =
|
109
|
-
assert_equal("hello world", output)
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_putFixedOptional
|
113
|
-
input = "hello world"
|
114
|
-
output = "".putFixedOptional(input)
|
115
|
-
assert_equal("\x01hello world", output)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_putFixedOptional_null
|
119
|
-
input = nil
|
120
|
-
output = "".putFixedOptional(input)
|
121
|
-
assert_equal("\xc0", output)
|
108
|
+
output = String.new.putFixed(input)
|
109
|
+
assert_equal("hello world".force_encoding("ASCII-8BIT"), output)
|
122
110
|
end
|
123
111
|
|
124
112
|
def test_putString
|
125
113
|
input = "hello world"
|
126
|
-
output =
|
127
|
-
assert_equal("\x0bhello world", output)
|
114
|
+
output = String.new.putString(input)
|
115
|
+
assert_equal("\x0bhello world".force_encoding("ASCII-8BIT"), output)
|
128
116
|
end
|
129
117
|
|
130
118
|
def test_putString_null
|
131
119
|
input = nil
|
132
|
-
output =
|
133
|
-
assert_equal("\xc0", output)
|
120
|
+
output = String.new.putString(input)
|
121
|
+
assert_equal("\xc0".force_encoding("ASCII-8BIT"), output)
|
134
122
|
end
|
135
123
|
|
136
124
|
def test_putBinary
|
137
125
|
input = "hello world"
|
138
|
-
output =
|
139
|
-
assert_equal("\x0bhello world", output)
|
126
|
+
output = String.new.putBinary(input)
|
127
|
+
assert_equal("\x0bhello world".force_encoding("ASCII-8BIT"), output)
|
140
128
|
end
|
141
129
|
|
142
130
|
def test_putBinary_null
|
143
131
|
input = nil
|
144
|
-
output =
|
145
|
-
assert_equal("\xc0", output)
|
132
|
+
output = String.new.putBinary(input)
|
133
|
+
assert_equal("\xc0".force_encoding("ASCII-8BIT"), output)
|
146
134
|
end
|
147
135
|
|
148
136
|
def test_putBool_true
|
149
137
|
input = true
|
150
|
-
output =
|
151
|
-
assert_equal("\x01", output)
|
138
|
+
output = String.new.putBool(input)
|
139
|
+
assert_equal("\x01".force_encoding("ASCII-8BIT"), output)
|
152
140
|
end
|
153
141
|
|
154
142
|
def test_putBool_false
|
155
143
|
input = false
|
156
|
-
output =
|
157
|
-
assert_equal("\x00", output)
|
144
|
+
output = String.new.putBool(input)
|
145
|
+
assert_equal("\x00".force_encoding("ASCII-8BIT"), output)
|
158
146
|
end
|
159
147
|
|
160
148
|
def test_putBool_null
|
161
149
|
input = nil
|
162
|
-
output =
|
163
|
-
assert_equal("\xc0", output)
|
150
|
+
output = String.new.putBool(input)
|
151
|
+
assert_equal("\xc0".force_encoding("ASCII-8BIT"), output)
|
164
152
|
end
|
165
153
|
|
166
154
|
def test_putF64
|
167
155
|
input = nil
|
168
|
-
output =
|
169
|
-
assert_equal("\xc0", output)
|
156
|
+
output = String.new.putF64(input)
|
157
|
+
assert_equal("\xc0".force_encoding("ASCII-8BIT"), output)
|
170
158
|
end
|
171
159
|
|
172
160
|
# Blink Specification 3.1
|
173
161
|
def test_getU8_64unsigned
|
174
|
-
input = "\x40"
|
175
|
-
output = input.getU8
|
162
|
+
input = StringIO.new("\x40")
|
163
|
+
output = input.getU8
|
176
164
|
assert_equal(64, output)
|
177
|
-
|
165
|
+
|
178
166
|
end
|
179
167
|
|
180
168
|
# Blink Specification 3.1
|
181
169
|
def test_getI8_64signed
|
182
|
-
input = "\x80\x01"
|
183
|
-
output = input.getI8
|
170
|
+
input = StringIO.new("\x80\x01")
|
171
|
+
output = input.getI8
|
184
172
|
assert_equal(64, output)
|
185
|
-
|
173
|
+
|
186
174
|
end
|
187
175
|
|
188
176
|
# Blink Specification 3.1
|
189
177
|
def test_getU16_4711unsigned
|
190
|
-
input = "\xa7\x49"
|
191
|
-
output = input.getU16
|
178
|
+
input = StringIO.new("\xa7\x49")
|
179
|
+
output = input.getU16
|
192
180
|
assert_equal(4711, output)
|
193
|
-
|
181
|
+
|
194
182
|
end
|
195
183
|
|
196
184
|
# Blink Specification 3.1
|
197
185
|
def test_getU32_4294967295unsigned
|
198
|
-
input = "\xc4\xff\xff\xff\xff"
|
199
|
-
output = input.getU32
|
186
|
+
input = StringIO.new("\xc4\xff\xff\xff\xff")
|
187
|
+
output = input.getU32
|
200
188
|
assert_equal(4294967295, output)
|
201
|
-
|
189
|
+
|
202
190
|
end
|
203
191
|
|
204
192
|
# Blink Specification 3.1
|
205
193
|
def test_getI8_minus64
|
206
|
-
input = "\x40"
|
207
|
-
output = input.getI8
|
194
|
+
input = StringIO.new("\x40")
|
195
|
+
output = input.getI8
|
208
196
|
assert_equal(-64, output)
|
209
|
-
|
197
|
+
|
210
198
|
end
|
211
199
|
|
212
200
|
# Blink Specification 3.1
|
213
201
|
def test_getI16_minus4711
|
214
|
-
input = "\x99\xb6"
|
215
|
-
output = input.getI16
|
202
|
+
input = StringIO.new("\x99\xb6")
|
203
|
+
output = input.getI16
|
216
204
|
assert_equal(-4711, output)
|
217
|
-
|
205
|
+
|
218
206
|
end
|
219
207
|
|
220
208
|
# Blink Specification 3.1
|
221
209
|
def test_getI32_minus2147483648
|
222
|
-
input = "\xc4\x00\x00\x00\x80"
|
223
|
-
output = input.getI32
|
210
|
+
input = StringIO.new("\xc4\x00\x00\x00\x80")
|
211
|
+
output = input.getI32
|
224
212
|
assert_equal(-2147483648, output)
|
225
|
-
|
213
|
+
|
226
214
|
end
|
227
215
|
|
228
216
|
def test_getBool_true
|
229
|
-
input = "\x01"
|
230
|
-
output = input.getBool
|
217
|
+
input = StringIO.new("\x01")
|
218
|
+
output = input.getBool
|
231
219
|
assert_equal(true, output)
|
232
|
-
|
220
|
+
|
233
221
|
end
|
234
222
|
|
235
223
|
def test_getBool_false
|
236
|
-
input = "\x00"
|
237
|
-
output = input.getBool
|
224
|
+
input = StringIO.new("\x00")
|
225
|
+
output = input.getBool
|
238
226
|
assert_equal(false, output)
|
239
|
-
|
227
|
+
|
240
228
|
end
|
241
229
|
|
242
230
|
def test_getBool_other
|
243
|
-
input = "\x02"
|
231
|
+
input = StringIO.new("\x02")
|
244
232
|
assert_raise Message::WeakError11 do
|
245
|
-
input.getBool
|
233
|
+
input.getBool
|
246
234
|
end
|
247
|
-
|
235
|
+
|
248
236
|
end
|
249
237
|
|
250
238
|
def test_getString
|
251
|
-
input = "\x0bhello world"
|
252
|
-
output = input.getString
|
239
|
+
input = StringIO.new("\x0bhello world")
|
240
|
+
output = input.getString
|
253
241
|
assert_equal("hello world", output)
|
254
|
-
|
242
|
+
|
255
243
|
end
|
256
244
|
|
257
245
|
def test_getString_null
|
258
|
-
input = "\xc0"
|
259
|
-
output = input.getString
|
246
|
+
input = StringIO.new("\xc0")
|
247
|
+
output = input.getString
|
260
248
|
assert_equal(nil, output)
|
261
|
-
|
249
|
+
|
262
250
|
end
|
263
251
|
|
264
252
|
def test_getString_eof
|
265
|
-
input = "\x01"
|
253
|
+
input = StringIO.new("\x01")
|
266
254
|
assert_raise Message::StrongError1 do
|
267
|
-
input.getString
|
255
|
+
input.getString
|
268
256
|
end
|
269
257
|
end
|
270
258
|
|
271
259
|
def test_getBinary
|
272
|
-
input = "\x0bhello world"
|
273
|
-
output = input.getBinary
|
260
|
+
input = StringIO.new("\x0bhello world")
|
261
|
+
output = input.getBinary
|
274
262
|
assert_equal("hello world", output)
|
275
|
-
|
263
|
+
|
276
264
|
end
|
277
265
|
|
278
266
|
def test_getBinary_null
|
279
|
-
input = "\xc0"
|
280
|
-
output = input.getBinary
|
267
|
+
input = StringIO.new("\xc0")
|
268
|
+
output = input.getBinary
|
281
269
|
assert_equal(nil, output)
|
282
|
-
|
270
|
+
|
283
271
|
end
|
284
272
|
|
285
273
|
def test_getBinary_eof
|
286
|
-
input = "\x01"
|
274
|
+
input = StringIO.new("\x01")
|
287
275
|
assert_raise Message::StrongError1 do
|
288
|
-
input.getBinary
|
276
|
+
input.getBinary
|
289
277
|
end
|
290
278
|
end
|
291
279
|
|
292
280
|
def test_getFixed
|
293
|
-
input = "hello world"
|
294
|
-
output = input.getFixed
|
281
|
+
input = StringIO.new("hello world")
|
282
|
+
output = input.getFixed("hello world".size)
|
295
283
|
assert_equal("hello world", output)
|
296
|
-
|
284
|
+
|
297
285
|
end
|
298
286
|
|
299
287
|
def test_getFixed_eof
|
300
|
-
input =
|
301
|
-
assert_raise Message::StrongError1 do
|
302
|
-
input.getFixed!(1)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
def test_getFixedOptional
|
307
|
-
input = "\x01hello world"
|
308
|
-
output = input.getFixedOptional!("hello world".size)
|
309
|
-
assert_equal("hello world", output)
|
310
|
-
assert_equal(0, input.size)
|
311
|
-
end
|
312
|
-
|
313
|
-
def test_getFixedOptional_null
|
314
|
-
input = "\xc0"
|
315
|
-
output = input.getFixedOptional!("hello world".size)
|
316
|
-
assert_equal(nil, output)
|
317
|
-
assert_equal(0, input.size)
|
318
|
-
end
|
319
|
-
|
320
|
-
def test_getFixedOptional_eof
|
321
|
-
input = "\x01"
|
288
|
+
input = StringIO.new
|
322
289
|
assert_raise Message::StrongError1 do
|
323
|
-
input.
|
290
|
+
input.getFixed(1)
|
324
291
|
end
|
325
292
|
end
|
326
293
|
|
327
294
|
def test_getI64_max
|
328
|
-
input = "\xC8\xff\xff\xff\xff\xff\xff\xff\x7f"
|
295
|
+
input = StringIO.new("\xC8\xff\xff\xff\xff\xff\xff\xff\x7f")
|
329
296
|
expected = 9223372036854775807
|
330
|
-
assert_equal(expected, input.getI64
|
297
|
+
assert_equal(expected, input.getI64)
|
331
298
|
end
|
332
299
|
|
333
300
|
def test_putI64_max
|
334
|
-
expected = "\xC8\xff\xff\xff\xff\xff\xff\xff\x7f"
|
301
|
+
expected = "\xC8\xff\xff\xff\xff\xff\xff\xff\x7f".force_encoding("ASCII-8BIT")
|
335
302
|
input = 9223372036854775807
|
336
|
-
assert_equal(expected,
|
303
|
+
assert_equal(expected, String.new.putI64(input))
|
337
304
|
end
|
338
305
|
|
339
306
|
def test_getI64_min
|
340
|
-
input = "\xC8\x00\x00\x00\x00\x00\x00\x00\x80"
|
307
|
+
input = StringIO.new("\xC8\x00\x00\x00\x00\x00\x00\x00\x80")
|
341
308
|
expected = -9223372036854775808
|
342
|
-
assert_equal(expected, input.getI64
|
309
|
+
assert_equal(expected, input.getI64)
|
343
310
|
end
|
344
311
|
|
345
312
|
def test_putI64_min
|
346
|
-
expected = "\xC8\x00\x00\x00\x00\x00\x00\x00\x80"
|
313
|
+
expected = "\xC8\x00\x00\x00\x00\x00\x00\x00\x80".force_encoding("ASCII-8BIT")
|
347
314
|
input = -9223372036854775808
|
348
|
-
assert_equal(expected,
|
315
|
+
assert_equal(expected, String.new.putI64(input))
|
349
316
|
end
|
350
317
|
|
351
318
|
def test_getI32_max
|
352
|
-
input = "\xC4\xff\xff\xff\x7f"
|
319
|
+
input = StringIO.new("\xC4\xff\xff\xff\x7f")
|
353
320
|
expected = 2147483647
|
354
|
-
assert_equal(expected, input.getI32
|
321
|
+
assert_equal(expected, input.getI32)
|
355
322
|
end
|
356
323
|
|
357
324
|
def test_getI32_min
|
358
|
-
input = "\xC4\x00\x00\x00\x80"
|
325
|
+
input = StringIO.new("\xC4\x00\x00\x00\x80")
|
359
326
|
expected = -2147483648
|
360
|
-
assert_equal(expected, input.getI32
|
327
|
+
assert_equal(expected, input.getI32)
|
361
328
|
end
|
362
329
|
|
363
330
|
def test_getI16_max
|
364
|
-
input = "\xC2\xff\x7f"
|
331
|
+
input = StringIO.new("\xC2\xff\x7f")
|
365
332
|
expected = 32767
|
366
|
-
assert_equal(expected, input.getI32
|
333
|
+
assert_equal(expected, input.getI32)
|
367
334
|
end
|
368
335
|
|
369
336
|
def test_getI16_min
|
370
|
-
input = "\xC2\x00\x80"
|
337
|
+
input = StringIO.new("\xC2\x00\x80")
|
371
338
|
expected = -32768
|
372
|
-
assert_equal(expected, input.getI32
|
339
|
+
assert_equal(expected, input.getI32)
|
373
340
|
end
|
374
341
|
|
375
342
|
end
|
data/test/tc_inputs.rb
CHANGED
@@ -16,16 +16,14 @@ testClass = Class.new(Test::Unit::TestCase) do
|
|
16
16
|
next if filename == ".." or filename == "."
|
17
17
|
|
18
18
|
test_name = "test_#{filename.sub(".blink", "")}"
|
19
|
-
inputs[test_name.to_sym] =
|
19
|
+
inputs[test_name.to_sym] = "#{root}/#{filename}"
|
20
20
|
|
21
21
|
define_method( test_name ) do
|
22
22
|
|
23
|
-
output = nil
|
24
|
-
|
25
23
|
# run and intercept stderr output
|
26
24
|
err = capture_stderr do
|
27
25
|
|
28
|
-
|
26
|
+
SlowBlink::Schema.read(inputs[__method__])
|
29
27
|
|
30
28
|
end
|
31
29
|
|