aboutsummaryrefslogtreecommitdiffhomepage
path: root/ruby/tests
diff options
context:
space:
mode:
authorGravatar Josh Haberman <jhaberman@gmail.com>2016-08-01 14:31:31 -0700
committerGravatar Josh Haberman <jhaberman@gmail.com>2016-08-01 14:34:54 -0700
commit3cec2ea8d61f5ebebb64af967db782e867da849f (patch)
tree5a3530bc9d584463560e50c7efba4e24440a4211 /ruby/tests
parenta207a2bd004f7b89699d3e52064dbed34603ae2d (diff)
Ruby: added custom Struct exception type and fixed Makefile.am.
Diffstat (limited to 'ruby/tests')
-rw-r--r--ruby/tests/well_known_types_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/ruby/tests/well_known_types_test.rb b/ruby/tests/well_known_types_test.rb
index 32e73f55..9b46632b 100644
--- a/ruby/tests/well_known_types_test.rb
+++ b/ruby/tests/well_known_types_test.rb
@@ -85,6 +85,30 @@ class TestWellKnownTypes < Test::Unit::TestCase
assert_equal(should_equal, struct.to_h)
assert_equal(should_equal["sublist"].length, struct["sublist"].length)
+
+ assert_raise Google::Protobuf::UnexpectedStructType do
+ struct[123] = 5
+ end
+
+ assert_raise Google::Protobuf::UnexpectedStructType do
+ struct[5] = Time.new
+ end
+
+ assert_raise Google::Protobuf::UnexpectedStructType do
+ struct[5] = [Time.new]
+ end
+
+ assert_raise Google::Protobuf::UnexpectedStructType do
+ struct[5] = {123 => 456}
+ end
+
+ assert_raise Google::Protobuf::UnexpectedStructType do
+ struct = Google::Protobuf::Struct.new
+ struct.fields["foo"] = Google::Protobuf::Value.new
+ # Tries to return a Ruby value for a Value class whose type
+ # hasn't been filled in.
+ struct["foo"]
+ end
end
def test_any