-
Notifications
You must be signed in to change notification settings - Fork 58
/
decoder_test.rb
34 lines (29 loc) · 955 Bytes
/
decoder_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'test_helper'
class DecoderTest < Test::Unit::TestCase
context "BERT Decoder complex type converter" do
should "convert nil" do
before = [:nil, :nil]
after = nil
assert_equal after, BERT::Decoder.convert(before)
end
should "convert nested nil" do
before = [[:nil, :nil], [[:nil, :nil]]]
after = [nil, [nil]]
assert_equal after, BERT::Decoder.convert(before)
end
should "convert hashes" do
before = [:dict, [:foo, 'bar']]
after = {:foo => 'bar'}
assert_equal after, BERT::Decoder.convert(before)
end
should "convert nested hashes" do
before = [:dict, [:foo, [:dict, [:baz, 'bar']]]]
after = {:foo => {:baz => 'bar'}}
assert_equal after, BERT::Decoder.convert(before)
end
should "leave other stuff alone" do
before = [1, 2.0, [:foo, 'bar']]
assert_equal before, BERT::Decoder.convert(before)
end
end
end