-
Notifications
You must be signed in to change notification settings - Fork 58
/
encoder_test.rb
32 lines (27 loc) · 901 Bytes
/
encoder_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
require 'test_helper'
class EncoderTest < Test::Unit::TestCase
context "BERT Encoder complex type converter" do
should "convert nil" do
assert_equal [:nil, :nil], BERT::Encoder.convert(nil)
end
should "convert nested nil" do
before = [nil, [nil]]
after = [[:nil, :nil], [[:nil, :nil]]]
assert_equal after, BERT::Encoder.convert(before)
end
should "convert hashes" do
before = {:foo => 'bar'}
after = [:dict, [:foo, 'bar']]
assert_equal after, BERT::Encoder.convert(before)
end
should "convert nested hashes" do
before = {:foo => {:baz => 'bar'}}
after = [:dict, [:foo, [:dict, [:baz, 'bar']]]]
assert_equal after, BERT::Encoder.convert(before)
end
should "leave other stuff alone" do
before = [1, 2.0, [:foo, 'bar']]
assert_equal before, BERT::Encoder.convert(before)
end
end
end