Explorar o código

Add Ruby tests for oneof cases. (#7385)

In Ruby, the oneof case returns a symbol with the name of the field that is set. These were not previously tested.
David L. Jones %!s(int64=5) %!d(string=hai) anos
pai
achega
94afb8ab36
Modificáronse 2 ficheiros con 3 adicións e 1 borrados
  1. 1 0
      ruby/tests/basic.rb
  2. 2 1
      ruby/tests/basic_proto2.rb

+ 1 - 0
ruby/tests/basic.rb

@@ -128,6 +128,7 @@ module BasicTest
       m.a = "foo"
       assert_equal "foo", m.a
       assert m.has_my_oneof?
+      assert_equal :a, m.my_oneof
       m.clear_a
       assert !m.has_my_oneof?
 

+ 2 - 1
ruby/tests/basic_proto2.rb

@@ -73,10 +73,11 @@ module BasicTestProto2
       m = OneofMessage.new
       assert !m.has_my_oneof?
       m.a = "foo"
+      assert m.has_my_oneof?
+      assert_equal :a, m.my_oneof
       assert m.has_a?
       assert OneofMessage.descriptor.lookup('a').has?(m)
       assert_equal "foo", m.a
-      assert m.has_my_oneof?
       assert !m.has_b?
       assert !OneofMessage.descriptor.lookup('b').has?(m)
       assert !m.has_c?