Fixed: incorrect tests
diff --git a/ruby/lib/google/protobuf/well_known_types.rb b/ruby/lib/google/protobuf/well_known_types.rb
index f86fe28..2d06ca2 100755
--- a/ruby/lib/google/protobuf/well_known_types.rb
+++ b/ruby/lib/google/protobuf/well_known_types.rb
@@ -138,13 +138,13 @@
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
diff --git a/ruby/tests/well_known_types_test.rb b/ruby/tests/well_known_types_test.rb
index 3e94ca0..2f345cd 100755
--- a/ruby/tests/well_known_types_test.rb
+++ b/ruby/tests/well_known_types_test.rb
@@ -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 @@
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 @@
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