slow_blink 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/ext/slow_blink/ext_schema_parser/parser.c +4 -4
  4. data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.c +5 -5
  5. data/ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c +31 -18
  6. data/lib/slow_blink/annotatable.rb +20 -17
  7. data/lib/slow_blink/annotation.rb +20 -18
  8. data/lib/slow_blink/binary.rb +20 -17
  9. data/lib/slow_blink/boolean.rb +20 -17
  10. data/lib/slow_blink/date.rb +20 -17
  11. data/lib/slow_blink/decimal.rb +20 -17
  12. data/lib/slow_blink/definition.rb +21 -19
  13. data/lib/slow_blink/enumeration.rb +30 -26
  14. data/lib/slow_blink/field.rb +20 -17
  15. data/lib/slow_blink/fixed.rb +20 -17
  16. data/lib/slow_blink/floating_point.rb +20 -17
  17. data/lib/slow_blink/group.rb +21 -18
  18. data/lib/slow_blink/incremental_annotation.rb +21 -18
  19. data/lib/slow_blink/integer.rb +20 -17
  20. data/lib/slow_blink/log.rb +20 -17
  21. data/lib/slow_blink/message/binary.rb +23 -18
  22. data/lib/slow_blink/message/boolean.rb +22 -17
  23. data/lib/slow_blink/message/date.rb +23 -18
  24. data/lib/slow_blink/message/decimal.rb +38 -21
  25. data/lib/slow_blink/message/enumeration.rb +31 -21
  26. data/lib/slow_blink/message/field.rb +23 -18
  27. data/lib/slow_blink/message/fixed.rb +23 -19
  28. data/lib/slow_blink/message/floating_point.rb +22 -17
  29. data/lib/slow_blink/message/group.rb +90 -55
  30. data/lib/slow_blink/message/integer.rb +51 -24
  31. data/lib/slow_blink/message/model.rb +197 -131
  32. data/lib/slow_blink/message/sequence.rb +31 -25
  33. data/lib/slow_blink/message/string.rb +23 -18
  34. data/lib/slow_blink/message/time.rb +31 -25
  35. data/lib/slow_blink/message/time_of_day.rb +24 -18
  36. data/lib/slow_blink/name_with_id.rb +20 -17
  37. data/lib/slow_blink/namespace.rb +22 -19
  38. data/lib/slow_blink/object.rb +20 -17
  39. data/lib/slow_blink/parse_error.rb +26 -0
  40. data/lib/slow_blink/ref.rb +20 -17
  41. data/lib/slow_blink/schema.rb +26 -24
  42. data/lib/slow_blink/schema_buffer.rb +20 -17
  43. data/lib/slow_blink/sequence.rb +20 -17
  44. data/lib/slow_blink/string.rb +20 -17
  45. data/lib/slow_blink/sym.rb +20 -17
  46. data/lib/slow_blink/time.rb +20 -17
  47. data/lib/slow_blink/time_of_day.rb +20 -17
  48. data/lib/slow_blink/type.rb +20 -17
  49. data/lib/slow_blink/version.rb +21 -18
  50. data/lib/slow_blink.rb +19 -17
  51. data/test/tc_compact_encoder.rb +64 -30
  52. data/test/tc_group.rb +0 -19
  53. data/test/tc_incr_annote.rb +0 -21
  54. data/test/tc_model_decimal.rb +94 -0
  55. data/test/tc_model_dynamic_group.rb +0 -19
  56. data/test/tc_model_extension.rb +0 -19
  57. data/test/tc_model_sequence_of_string.rb +29 -0
  58. data/test/tc_model_static_group.rb +0 -19
  59. data/test/tc_model_think_blink.rb +0 -19
  60. data/test/tc_types.rb +0 -19
  61. metadata +8 -4
  62. data/lib/slow_blink/compact_encoder.rb +0 -72
  63. data/lib/slow_blink/error.rb +0 -23
@@ -1,21 +1,24 @@
1
- # Copyright (c) 2016 Cameron Harper
1
+ # @license
2
+ #
3
+ # Copyright (c) 2016 Cameron Harper
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
2
14
  #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
19
22
 
20
23
  module SlowBlink
21
24
 
@@ -1,21 +1,24 @@
1
- # Copyright (c) 2016 Cameron Harper
1
+ # @license
2
+ #
3
+ # Copyright (c) 2016 Cameron Harper
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
2
14
  #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
19
22
 
20
23
  module SlowBlink
21
24
 
@@ -1,22 +1,25 @@
1
- # Copyright (c) 2016 Cameron Harper
1
+ # @license
2
+ #
3
+ # Copyright (c) 2016 Cameron Harper
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
2
14
  #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
19
22
 
20
23
  module SlowBlink
21
- VERSION = '0.0.5'.freeze
24
+ VERSION = '0.0.6'.freeze
22
25
  end
data/lib/slow_blink.rb CHANGED
@@ -1,21 +1,23 @@
1
- # Copyright (c) 2016 Cameron Harper
1
+ # @license
2
+ #
3
+ # Copyright (c) 2016 Cameron Harper
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
2
14
  #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.# ~~~
19
21
 
20
22
  require 'slow_blink/schema'
21
23
  require 'slow_blink/message/model'
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
@@ -38,7 +19,7 @@ class TestCompactEncoder < Test::Unit::TestCase
38
19
 
39
20
  def test_putU8_tooBig
40
21
  input = 0x100
41
- assert_raise do
22
+ assert_raise RangeError do
42
23
  "".putU8(input)
43
24
  end
44
25
  end
@@ -68,6 +49,18 @@ class TestCompactEncoder < Test::Unit::TestCase
68
49
  assert_equal("\x40", output)
69
50
  end
70
51
 
52
+ def test_putU16_16383
53
+ input = 16383
54
+ output = "".putU16(input)
55
+ assert_equal("\xBf\xff", output)
56
+ end
57
+
58
+ def test_putI16_16383
59
+ input = 16383
60
+ output = "".putI16(input)
61
+ assert_equal("\xC2\xff\x3f", output)
62
+ end
63
+
71
64
  # Blink Specification 3.1
72
65
  def test_putI8_64signed
73
66
  input = 64
@@ -248,7 +241,7 @@ class TestCompactEncoder < Test::Unit::TestCase
248
241
 
249
242
  def test_getBool_other
250
243
  input = "\x02"
251
- assert_raise do
244
+ assert_raise Message::WeakError11 do
252
245
  input.getBool!
253
246
  end
254
247
  assert_equal(0, input.size)
@@ -270,7 +263,7 @@ class TestCompactEncoder < Test::Unit::TestCase
270
263
 
271
264
  def test_getString_eof
272
265
  input = "\x01"
273
- assert_raise do
266
+ assert_raise Message::StrongError1 do
274
267
  input.getString!
275
268
  end
276
269
  end
@@ -291,7 +284,7 @@ class TestCompactEncoder < Test::Unit::TestCase
291
284
 
292
285
  def test_getBinary_eof
293
286
  input = "\x01"
294
- assert_raise do
287
+ assert_raise Message::StrongError1 do
295
288
  input.getBinary!
296
289
  end
297
290
  end
@@ -305,7 +298,7 @@ class TestCompactEncoder < Test::Unit::TestCase
305
298
 
306
299
  def test_getFixed_eof
307
300
  input = ""
308
- assert_raise do
301
+ assert_raise Message::StrongError1 do
309
302
  input.getFixed!(1)
310
303
  end
311
304
  end
@@ -326,16 +319,57 @@ class TestCompactEncoder < Test::Unit::TestCase
326
319
 
327
320
  def test_getFixedOptional_eof
328
321
  input = "\x01"
329
- assert_raise do
322
+ assert_raise Message::StrongError1 do
330
323
  input.getFixedOptional!(1)
331
324
  end
332
325
  end
333
326
 
334
- def test_getU32_13548
335
- input = "\x01"
336
- assert_raise do
337
- input.getFixedOptional!(1)
338
- end
327
+ def test_getI64_max
328
+ input = "\xC8\xff\xff\xff\xff\xff\xff\xff\x7f"
329
+ expected = 9223372036854775807
330
+ assert_equal(expected, input.getI64!)
331
+ end
332
+
333
+ def test_putI64_max
334
+ expected = "\xC8\xff\xff\xff\xff\xff\xff\xff\x7f"
335
+ input = 9223372036854775807
336
+ assert_equal(expected, "".putI64(input))
337
+ end
338
+
339
+ def test_getI64_min
340
+ input = "\xC8\x00\x00\x00\x00\x00\x00\x00\x80"
341
+ expected = -9223372036854775808
342
+ assert_equal(expected, input.getI64!)
343
+ end
344
+
345
+ def test_putI64_min
346
+ expected = "\xC8\x00\x00\x00\x00\x00\x00\x00\x80"
347
+ input = -9223372036854775808
348
+ assert_equal(expected, "".putI64(input))
349
+ end
350
+
351
+ def test_getI32_max
352
+ input = "\xC4\xff\xff\xff\x7f"
353
+ expected = 2147483647
354
+ assert_equal(expected, input.getI32!)
355
+ end
356
+
357
+ def test_getI32_min
358
+ input = "\xC4\x00\x00\x00\x80"
359
+ expected = -2147483648
360
+ assert_equal(expected, input.getI32!)
361
+ end
362
+
363
+ def test_getI16_max
364
+ input = "\xC2\xff\x7f"
365
+ expected = 32767
366
+ assert_equal(expected, input.getI32!)
367
+ end
368
+
369
+ def test_getI16_min
370
+ input = "\xC2\x00\x80"
371
+ expected = -32768
372
+ assert_equal(expected, input.getI32!)
339
373
  end
340
374
 
341
375
  end
data/test/tc_group.rb CHANGED
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
@@ -36,8 +17,6 @@ class TestIncrAnnote < Test::Unit::TestCase
36
17
 
37
18
  schema = Schema.new(SchemaBuffer.new(raw))
38
19
 
39
- assert_equal(schema.annotes
40
-
41
20
  end
42
21
 
43
22
  end
@@ -0,0 +1,94 @@
1
+ require "test/unit"
2
+ require 'slow_blink'
3
+
4
+ class TestModelDecimal < Test::Unit::TestCase
5
+
6
+ include SlowBlink
7
+
8
+ def setup
9
+ schema = Schema.new(SchemaBuffer.new("Test/0 -> decimal Field"))
10
+ @model = Message::Model.new(schema)
11
+ end
12
+
13
+ def test_init_integer
14
+ assert_equal(42, @model.group("Test").new("Field" => 42)["Field"])
15
+ end
16
+
17
+ def test_init_float
18
+ assert_equal(42.1, @model.group("Test").new("Field" => 42.1)["Field"])
19
+ end
20
+
21
+ def test_init_scientific
22
+ assert_equal(4210, @model.group("Test").new("Field" => "42.1E2")["Field"])
23
+ end
24
+
25
+ def test_init_scientific_negative_exponent
26
+ assert_equal(0.421, @model.group("Test").new("Field" => "42.1E-2")["Field"])
27
+ end
28
+
29
+ def test_encode_compact_integer
30
+
31
+ output = @model.group("Test").new("Field" => 42).encode_compact.force_encoding("ASCII-8BIT")
32
+ expected = "\x03\x00\x00\x2a".force_encoding("ASCII-8BIT")
33
+ assert_equal(expected, output)
34
+
35
+ end
36
+
37
+ def test_encode_compact_float
38
+
39
+ output = @model.group("Test").new("Field" => 42.1).encode_compact.force_encoding("ASCII-8BIT")
40
+ expected = "\x04\x00\x7f\xa5\x06".force_encoding("ASCII-8BIT")
41
+ assert_equal(expected, output)
42
+
43
+ end
44
+
45
+ def test_encode_compact_scientific
46
+
47
+ output = @model.group("Test").new("Field" => "42.1E2").encode_compact.force_encoding("ASCII-8BIT")
48
+ expected = "\x04\x00\x01\xa5\x06".force_encoding("ASCII-8BIT")
49
+ assert_equal(expected, output)
50
+
51
+ end
52
+
53
+ def test_encode_compact_scientific_negative_exponent
54
+
55
+ output = @model.group("Test").new("Field" => "42.1E-2").encode_compact.force_encoding("ASCII-8BIT")
56
+ expected = "\x04\x00\x7d\xa5\x06".force_encoding("ASCII-8BIT")
57
+ assert_equal(expected, output)
58
+
59
+ end
60
+
61
+ def test_decode_compact_integer
62
+
63
+ input = "\x03\x00\x00\x2a".force_encoding("ASCII-8BIT")
64
+ expected = 42
65
+ assert_equal(expected, @model.decode_compact(input)["Field"])
66
+
67
+ end
68
+
69
+ def test_decode_compact_float
70
+
71
+ input = "\x04\x00\x7f\xa5\x06".force_encoding("ASCII-8BIT")
72
+ expected = 42.1
73
+ assert_equal(expected, @model.decode_compact(input)["Field"])
74
+
75
+ end
76
+
77
+ def test_decode_compact_scientific
78
+
79
+ input = "\x04\x00\x01\xa5\x06".force_encoding("ASCII-8BIT")
80
+ expected = 4210
81
+ assert_equal(expected, @model.decode_compact(input)["Field"])
82
+
83
+ end
84
+
85
+ def test_decode_compact_scientific_negative_exponent
86
+
87
+ input = "\x04\x00\x7d\xa5\x06".force_encoding("ASCII-8BIT")
88
+ expected = 0.421
89
+ assert_equal(expected, @model.decode_compact(input)["Field"])
90
+
91
+ end
92
+
93
+
94
+ end
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
@@ -0,0 +1,29 @@
1
+ require "test/unit"
2
+ require 'slow_blink'
3
+
4
+ class TestModelSequenceOfString < Test::Unit::TestCase
5
+
6
+ include SlowBlink
7
+
8
+ def setup
9
+ schema = Schema.new(SchemaBuffer.new("Test/0 -> string [] Field"))
10
+ @model = Message::Model.new(schema)
11
+ end
12
+
13
+ def test_init
14
+ assert_equal(["hello", "world"], @model.group("Test").new("Field" => ["hello", "world"])["Field"])
15
+ end
16
+
17
+ def test_encode_compact
18
+ output = @model.group("Test").new("Field" => ["hello", "world"]).encode_compact.force_encoding("ASCII-8BIT")
19
+ expected = "\x0e\x00\x02\x05hello\x05world".force_encoding("ASCII-8BIT")
20
+ assert_equal(expected, output)
21
+ end
22
+
23
+ def test_decode_compact
24
+ input = "\x0e\x00\x02\x05hello\x05world".force_encoding("ASCII-8BIT")
25
+ expected = ["hello", "world"]
26
+ assert_equal(expected, @model.decode_compact(input)["Field"])
27
+ end
28
+
29
+ end
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3
 
data/test/tc_types.rb CHANGED
@@ -1,22 +1,3 @@
1
- # Copyright (c) 2016 Cameron Harper
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- # this software and associated documentation files (the "Software"), to deal in
5
- # the Software without restriction, including without limitation the rights to
6
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
- # the Software, and to permit persons to whom the Software is furnished to do so,
8
- # subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
20
1
  require "test/unit"
21
2
  require 'slow_blink'
22
3