Fixed: incorrect tests
This commit is contained in:
parent
947a51a464
commit
4d94a7cd93
@ -138,13 +138,13 @@ module Google
|
||||
end
|
||||
|
||||
def self.from_ruby(value)
|
||||
Value.new.from_ruby(value)
|
||||
self.new.from_ruby(value)
|
||||
end
|
||||
|
||||
def from_ruby(value)
|
||||
case value
|
||||
when NilClass
|
||||
self.null_value = 0
|
||||
self.null_value = :NULL_VALUE
|
||||
when Numeric
|
||||
self.number_value = value
|
||||
when String
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'test/unit'
|
||||
require 'google/protobuf/well_known_types'
|
||||
require 'lib/google/protobuf/well_known_types'
|
||||
|
||||
class TestWellKnownTypes < Test::Unit::TestCase
|
||||
def test_timestamp
|
||||
@ -218,7 +218,7 @@ class TestWellKnownTypes < Test::Unit::TestCase
|
||||
|
||||
def test_from_ruby
|
||||
pb = Google::Protobuf::Value.from_ruby(nil)
|
||||
assert_equal pb.null_value, 0
|
||||
assert_equal pb.null_value, :NULL_VALUE
|
||||
|
||||
pb = Google::Protobuf::Value.from_ruby(1.23)
|
||||
assert_equal pb.number_value, 1.23
|
||||
@ -232,16 +232,16 @@ class TestWellKnownTypes < Test::Unit::TestCase
|
||||
pb = Google::Protobuf::Value.from_ruby(false)
|
||||
assert_equal pb.bool_value, false
|
||||
|
||||
pb = Google::Protobuf::Value.from_ruby(Google::Protobuf::Struct.from_hash({ a: 1, b: '2', c: [1, 2, 3] }))
|
||||
assert_equal pb.struct_value, Google::Protobuf::Struct.from_hash({ a: 1, b: '2', c: [1, 2, 3] })
|
||||
pb = Google::Protobuf::Value.from_ruby(Google::Protobuf::Struct.from_hash({ 'a' => 1, 'b' => '2', 'c' => [1, 2, 3], 'd' => nil, 'e' => true }))
|
||||
assert_equal pb.struct_value, Google::Protobuf::Struct.from_hash({ 'a' => 1, 'b' => '2', 'c' => [1, 2, 3], 'd' => nil, 'e' => true })
|
||||
|
||||
pb = Google::Protobuf::Value.from_ruby({ a: 1, b: '2', c: [1, 2, 3] })
|
||||
assert_equal pb.struct_value, Google::Protobuf::Struct.from_hash({ a: 1, b: '2', c: [1, 2, 3] })
|
||||
pb = Google::Protobuf::Value.from_ruby({ 'a' => 1, 'b' => '2', 'c' => [1, 2, 3], 'd' => nil, 'e' => true })
|
||||
assert_equal pb.struct_value, Google::Protobuf::Struct.from_hash({ 'a' => 1, 'b' => '2', 'c' => [1, 2, 3], 'd' => nil, 'e' => true })
|
||||
|
||||
pb = Google::Protobuf::Value.from_ruby(Google::Protobuf::ListValue.from_a([1, 2, 3]))
|
||||
assert_equal pb.struct_value, Google::Protobuf::ListValue.from_a([1, 2, 3])
|
||||
assert_equal pb.list_value, Google::Protobuf::ListValue.from_a([1, 2, 3])
|
||||
|
||||
pb = Google::Protobuf::Value.from_ruby([1, 2, 3])
|
||||
assert_equal pb.struct_value, Google::Protobuf::ListValue.from_a([1, 2, 3])
|
||||
assert_equal pb.list_value, Google::Protobuf::ListValue.from_a([1, 2, 3])
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user