msgpack 1.4.4.pre1-java → 1.4.5-java
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/lib/msgpack/msgpack.jar +0 -0
- data/lib/msgpack/symbol.rb +8 -1
- data/lib/msgpack/version.rb +1 -1
- metadata +7 -55
- data/spec/cases.json +0 -1
- data/spec/cases.msg +0 -0
- data/spec/cases_compact.msg +0 -0
- data/spec/cases_spec.rb +0 -39
- data/spec/cruby/buffer_io_spec.rb +0 -255
- data/spec/cruby/buffer_packer.rb +0 -29
- data/spec/cruby/buffer_spec.rb +0 -575
- data/spec/cruby/buffer_unpacker.rb +0 -19
- data/spec/cruby/unpacker_spec.rb +0 -70
- data/spec/ext_value_spec.rb +0 -99
- data/spec/exttypes.rb +0 -51
- data/spec/factory_spec.rb +0 -384
- data/spec/format_spec.rb +0 -301
- data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
- data/spec/jruby/unpacker_spec.rb +0 -186
- data/spec/msgpack_spec.rb +0 -214
- data/spec/pack_spec.rb +0 -61
- data/spec/packer_spec.rb +0 -575
- data/spec/random_compat.rb +0 -24
- data/spec/spec_helper.rb +0 -65
- data/spec/timestamp_spec.rb +0 -161
- data/spec/unpack_spec.rb +0 -57
- data/spec/unpacker_spec.rb +0 -828
data/spec/timestamp_spec.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
IS_JRUBY = Kernel.const_defined?(:JRUBY_VERSION)
|
6
|
-
|
7
|
-
describe MessagePack::Timestamp do
|
8
|
-
describe 'malformed format' do
|
9
|
-
it do
|
10
|
-
expect do
|
11
|
-
MessagePack::Timestamp.from_msgpack_ext([0xd4, 0x00].pack("C*"))
|
12
|
-
end.to raise_error(MessagePack::MalformedFormatError)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'register_type with Time' do
|
17
|
-
let(:factory) do
|
18
|
-
factory = MessagePack::Factory.new
|
19
|
-
factory.register_type(
|
20
|
-
MessagePack::Timestamp::TYPE,
|
21
|
-
Time,
|
22
|
-
packer: MessagePack::Time::Packer,
|
23
|
-
unpacker: MessagePack::Time::Unpacker
|
24
|
-
)
|
25
|
-
factory
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:time) { Time.local(2019, 6, 17, 1, 2, 3, 123_456_789 / 1000.0) }
|
29
|
-
it 'serializes and deserializes Time' do
|
30
|
-
prefix_fixext8_with_type_id = [0xd7, -1].pack("c*")
|
31
|
-
|
32
|
-
packed = factory.pack(time)
|
33
|
-
expect(packed).to start_with(prefix_fixext8_with_type_id)
|
34
|
-
expect(packed.size).to eq(10)
|
35
|
-
unpacked = factory.unpack(packed)
|
36
|
-
expect(unpacked.to_i).to eq(time.to_i)
|
37
|
-
expect(unpacked.to_f).to eq(time.to_f)
|
38
|
-
# expect(unpacked).to eq(time) # we can't do it because of nsec (rational vs float?)
|
39
|
-
end
|
40
|
-
|
41
|
-
let(:time_without_nsec) { Time.local(2019, 6, 17, 1, 2, 3, 0) }
|
42
|
-
it 'serializes time without nanosec as fixext4' do
|
43
|
-
prefix_fixext4_with_type_id = [0xd6, -1].pack("c*")
|
44
|
-
|
45
|
-
packed = factory.pack(time_without_nsec)
|
46
|
-
expect(packed).to start_with(prefix_fixext4_with_type_id)
|
47
|
-
expect(packed.size).to eq(6)
|
48
|
-
unpacked = factory.unpack(packed)
|
49
|
-
expect(unpacked).to eq(time_without_nsec)
|
50
|
-
end
|
51
|
-
|
52
|
-
let(:time_after_2514) { Time.at(1 << 34) } # the max num of 34bit int means 2514-05-30 01:53:04 UTC
|
53
|
-
it 'serializes time after 2038 as ext8' do
|
54
|
-
prefix_ext8_with_12bytes_payload_and_type_id = [0xc7, 12, -1].pack("c*")
|
55
|
-
|
56
|
-
expect(time_after_2514.to_i).to be > 0xffffffff
|
57
|
-
packed = factory.pack(time_after_2514)
|
58
|
-
expect(packed).to start_with(prefix_ext8_with_12bytes_payload_and_type_id)
|
59
|
-
expect(packed.size).to eq(15)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'runs correctly (regression)' do
|
63
|
-
expect(factory.unpack(factory.pack(Time.utc(2200)))).to eq(Time.utc(2200))
|
64
|
-
end
|
65
|
-
|
66
|
-
let(:time32_max) { Time.new(2106, 2, 7, 6, 28, 15, "+00:00") }
|
67
|
-
it 'is serialized into timestamp32' do
|
68
|
-
expect(factory.pack(time32_max).size).to be 6
|
69
|
-
expect(factory.unpack(factory.pack(time32_max)).utc).to eq(time32_max)
|
70
|
-
end
|
71
|
-
|
72
|
-
let(:time64_min) { Time.new(2106, 2, 7, 6, 28, 16, "+00:00") }
|
73
|
-
it 'is serialized into timestamp64' do
|
74
|
-
expect(factory.pack(time64_min).size).to be 10
|
75
|
-
expect(factory.unpack(factory.pack(time64_min)).utc).to eq(time64_min)
|
76
|
-
end
|
77
|
-
|
78
|
-
let(:time64_max) { Time.at(Time.new(2514, 5, 30, 1, 53, 3, "+00:00").to_i, 999999999 / 1000.0r).utc } # TODO: use Time.at(sec, nsec, :nsec) when removing Ruby 2.4 from the list
|
79
|
-
it 'is serialized into timestamp64' do
|
80
|
-
expect(factory.pack(time64_max).size).to be 10
|
81
|
-
expect(factory.unpack(factory.pack(time64_max)).utc).to eq(time64_max)
|
82
|
-
end
|
83
|
-
|
84
|
-
let(:time96_positive_min) { Time.new(2514, 5, 30, 1, 53, 4, "+00:00") }
|
85
|
-
it 'is serialized into timestamp96' do
|
86
|
-
expect(factory.pack(time96_positive_min).size).to be 15
|
87
|
-
expect(factory.unpack(factory.pack(time96_positive_min)).utc).to eq(time96_positive_min)
|
88
|
-
end
|
89
|
-
|
90
|
-
let(:time96_min) { Time.at(-2**63).utc }
|
91
|
-
it 'is serialized into timestamp96' do
|
92
|
-
skip if IS_JRUBY # JRuby cannot handle numerics larger than long
|
93
|
-
expect(factory.pack(time96_min).size).to be 15
|
94
|
-
expect(factory.unpack(factory.pack(time96_min)).utc).to eq(time96_min)
|
95
|
-
end
|
96
|
-
|
97
|
-
let(:time96_max) { Time.at(2**63 - 1).utc }
|
98
|
-
it 'is serialized into timestamp96' do
|
99
|
-
skip if IS_JRUBY # JRuby cannot handle numerics larger than long
|
100
|
-
expect(factory.pack(time96_max).size).to be 15
|
101
|
-
expect(factory.unpack(factory.pack(time96_max)).utc).to eq(time96_max)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe 'register_type with MessagePack::Timestamp' do
|
106
|
-
let(:factory) do
|
107
|
-
factory = MessagePack::Factory.new
|
108
|
-
factory.register_type(MessagePack::Timestamp::TYPE, MessagePack::Timestamp)
|
109
|
-
factory
|
110
|
-
end
|
111
|
-
|
112
|
-
let(:timestamp) { MessagePack::Timestamp.new(Time.now.tv_sec, 123_456_789) }
|
113
|
-
it 'serializes and deserializes MessagePack::Timestamp' do
|
114
|
-
packed = factory.pack(timestamp)
|
115
|
-
unpacked = factory.unpack(packed)
|
116
|
-
expect(unpacked).to eq(timestamp)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe 'timestamp32' do
|
121
|
-
it 'handles [1, 0]' do
|
122
|
-
t = MessagePack::Timestamp.new(1, 0)
|
123
|
-
|
124
|
-
payload = t.to_msgpack_ext
|
125
|
-
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
126
|
-
|
127
|
-
expect(unpacked).to eq(t)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe 'timestamp64' do
|
132
|
-
it 'handles [1, 1]' do
|
133
|
-
t = MessagePack::Timestamp.new(1, 1)
|
134
|
-
|
135
|
-
payload = t.to_msgpack_ext
|
136
|
-
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
137
|
-
|
138
|
-
expect(unpacked).to eq(t)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe 'timestamp96' do
|
143
|
-
it 'handles [-1, 0]' do
|
144
|
-
t = MessagePack::Timestamp.new(-1, 0)
|
145
|
-
|
146
|
-
payload = t.to_msgpack_ext
|
147
|
-
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
148
|
-
|
149
|
-
expect(unpacked).to eq(t)
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'handles [-1, 999_999_999]' do
|
153
|
-
t = MessagePack::Timestamp.new(-1, 999_999_999)
|
154
|
-
|
155
|
-
payload = t.to_msgpack_ext
|
156
|
-
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
157
|
-
|
158
|
-
expect(unpacked).to eq(t)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
data/spec/unpack_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# encoding: ascii-8bit
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
require 'stringio'
|
5
|
-
if defined?(Encoding)
|
6
|
-
Encoding.default_external = 'ASCII-8BIT'
|
7
|
-
end
|
8
|
-
|
9
|
-
describe MessagePack do
|
10
|
-
it 'MessagePack.unpack symbolize_keys' do
|
11
|
-
symbolized_hash = {:a => 'b', :c => 'd'}
|
12
|
-
MessagePack.load(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
|
13
|
-
MessagePack.unpack(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'Unpacker#read symbolize_keys' do
|
17
|
-
unpacker = MessagePack::Unpacker.new(:symbolize_keys => true)
|
18
|
-
symbolized_hash = {:a => 'b', :c => 'd'}
|
19
|
-
unpacker.feed(MessagePack.pack(symbolized_hash)).read.should == symbolized_hash
|
20
|
-
end
|
21
|
-
|
22
|
-
it "msgpack str 8 type" do
|
23
|
-
MessagePack.unpack([0xd9, 0x00].pack('C*')).should == ""
|
24
|
-
MessagePack.unpack([0xd9, 0x01].pack('C*') + 'a').should == "a"
|
25
|
-
MessagePack.unpack([0xd9, 0x02].pack('C*') + 'aa').should == "aa"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "msgpack str 16 type" do
|
29
|
-
MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).should == ""
|
30
|
-
MessagePack.unpack([0xda, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
31
|
-
MessagePack.unpack([0xda, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "msgpack str 32 type" do
|
35
|
-
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
|
36
|
-
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
37
|
-
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "msgpack bin 8 type" do
|
41
|
-
MessagePack.unpack([0xc4, 0x00].pack('C*')).should == ""
|
42
|
-
MessagePack.unpack([0xc4, 0x01].pack('C*') + 'a').should == "a"
|
43
|
-
MessagePack.unpack([0xc4, 0x02].pack('C*') + 'aa').should == "aa"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "msgpack bin 16 type" do
|
47
|
-
MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).should == ""
|
48
|
-
MessagePack.unpack([0xc5, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
49
|
-
MessagePack.unpack([0xc5, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "msgpack bin 32 type" do
|
53
|
-
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
|
54
|
-
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
55
|
-
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
56
|
-
end
|
57
|
-
end
|