Lines Matching refs:m
16 m = proto_module::TestMessage.new
17 assert m.optional_int32 == 0
18 assert m.optional_int64 == 0
19 assert m.optional_uint32 == 0
20 assert m.optional_uint64 == 0
21 assert m.optional_bool == false
22 assert m.optional_float == 0.0
23 assert m.optional_double == 0.0
24 assert m.optional_string == ""
25 assert m.optional_bytes == ""
26 assert m.optional_msg == nil
27 assert m.optional_enum == :Default
31 m = proto_module::TestMessage.new
32 m.optional_int32 = -42
33 assert m.optional_int32 == -42
34 m.optional_int64 = -0x1_0000_0000
35 assert m.optional_int64 == -0x1_0000_0000
36 m.optional_uint32 = 0x9000_0000
37 assert m.optional_uint32 == 0x9000_0000
38 m.optional_uint64 = 0x9000_0000_0000_0000
39 assert m.optional_uint64 == 0x9000_0000_0000_0000
40 m.optional_bool = true
41 assert m.optional_bool == true
42 m.optional_float = 0.5
43 assert m.optional_float == 0.5
44 m.optional_double = 0.5
45 assert m.optional_double == 0.5
46 m.optional_string = "hello"
47 assert m.optional_string == "hello"
48 m.optional_string = :hello
49 assert m.optional_string == "hello"
50 m.optional_bytes = "world".encode!('ASCII-8BIT')
51 assert m.optional_bytes == "world"
52 m.optional_msg = proto_module::TestMessage2.new(:foo => 42)
53 assert m.optional_msg == proto_module::TestMessage2.new(:foo => 42)
54 m.optional_msg = nil
55 assert m.optional_msg == nil
56 m.optional_enum = :C
57 assert m.optional_enum == :C
58 m.optional_enum = 'C'
59 assert m.optional_enum == :C
63 m = proto_module::TestMessage.new(:optional_int32 => -42,
67 assert m.optional_int32 == -42
68 assert m.optional_msg.class == proto_module::TestMessage2
69 assert m.repeated_string.length == 3
70 assert m.optional_enum == :C
71 assert m.repeated_string[0] == "hello"
72 assert m.repeated_string[1] == "there"
73 assert m.repeated_string[2] == "world"
77 m = proto_module::TestMessage.new(:optional_enum => 'C', :repeated_enum => ['A', 'B'])
78 assert_equal :C, m.optional_enum
79 assert_equal [:A, :B], m.repeated_enum
81 m = proto_module::TestMessage.new(:optional_string => :foo, :repeated_string => [:foo, :bar])
82 assert_equal 'foo', m.optional_string
83 assert_equal ['foo', 'bar'], m.repeated_string
87 …m = proto_module::TestMessage.new(:optional_enum => nil, :optional_int32 => nil, :optional_string …
89 assert_equal :Default, m.optional_enum
90 assert_equal 0, m.optional_int32
91 assert_equal "", m.optional_string
92 assert_nil m.optional_msg
96 m = proto_module::TestEmbeddedMessageParent.new(
102 assert_equal 2, m.number
103 assert_equal [10, 20, 30], m.repeated_number
105 assert_not_nil m.child_msg
106 assert_not_nil m.child_msg.sub_child
107 assert_equal m.child_msg.sub_child.optional_int32, 1
109 assert_not_nil m.repeated_msg
110 assert_equal 1, m.repeated_msg.length
111 assert_equal 3, m.repeated_msg.first.sub_child.optional_int32
115 m = proto_module::TestMessage.new(
121 assert_equal expected, m.inspect
122 assert_equal expected, m.to_s
124 m = proto_module::OneofMessage.new(:b => -42)
126 assert_equal expected, m.inspect
127 assert_equal expected, m.to_s
156 m = proto_module::TestMessage.new
158 m.optional_int32 = "hello"
166 m.optional_string = 42
169 m.optional_string = nil
172 m.optional_bool = 42
175 m.optional_msg = proto_module::TestMessage.new # expects TestMessage2
179 m.repeated_int32 = [] # needs RepeatedField
183 m.repeated_int32.push "hello"
187 m.repeated_msg.push proto_module::TestMessage.new
192 m = proto_module::TestMessage.new
196 m.optional_bytes = "Test string ASCII".encode!('ASCII')
197 assert m.optional_bytes.frozen?
198 assert_equal Encoding::ASCII_8BIT, m.optional_bytes.encoding
199 assert_equal "Test string ASCII", m.optional_bytes
202 m.optional_bytes = "Test string UTF-8 \u0100".encode!('UTF-8')
206 m.optional_string = ["FFFF"].pack('H*')
210 m.optional_bytes = ["FFFF"].pack('H*')
211 m.optional_string = "\u0100"
214 m.optional_string = "asdf".encode!('UTF-8')
215 assert_raise(FrozenErrorType) { m.optional_string.encode!('ASCII-8BIT') }
251 m = proto_module::TestMessage.new
252 l.push m
255 m = proto_module::TestMessage.new
256 m.repeated_int32 = l
257 assert m.repeated_int32 == [5, 2, 3, 4, 7, 8]
258 assert m.repeated_int32.object_id == l.object_id
260 assert m.repeated_int32.pop == 42
287 m = proto_module::TestMessage.new
288 assert m.repeated_string == []
289 m.repeated_string << 'ok'
290 m.repeated_string.push('ok2')
291 assert m.repeated_string == ['ok', 'ok2']
292 m.repeated_string += ['ok3']
293 assert m.repeated_string == ['ok', 'ok2', 'ok3']
396 m = Google::Protobuf::Map.new(:string, :int32)
397 m["asdf"] = 1
398 assert m["asdf"] == 1
399 m["jkl;"] = 42
400 assert m == { "jkl;" => 42, "asdf" => 1 }
401 assert m.has_key?("asdf")
402 assert !m.has_key?("qwerty")
403 assert m.length == 2
405 m2 = m.dup
406 assert_equal m, m2
407 assert m.hash != 0
408 assert_equal m.hash, m2.hash
411 m.each { |k,v| collected[v] = k }
414 assert m.delete("asdf") == 1
415 assert !m.has_key?("asdf")
416 assert m["asdf"] == nil
417 assert !m.has_key?("asdf")
422 assert m.inspect == "{\"jkl;\"=>42}"
424 assert m.keys == ["jkl;"]
425 assert m.values == [42]
427 m.clear
428 assert m.length == 0
429 assert m == {}
432 m[1] = 1
435 m["asdf"] = 0x1_0000_0000
440 m = Google::Protobuf::Map.new(:string, :int32,
442 assert m == {"a" => 1, "c" => 3, "b" => 2}
446 m = Google::Protobuf::Map.new(:int32, :int32)
447 m[1] = 42
448 m[-1] = 42
450 m[0x8000_0000] = 1
453 m["asdf"] = 1
456 m = Google::Protobuf::Map.new(:int64, :int32)
457 m[0x1000_0000_0000_0000] = 1
459 m[0x1_0000_0000_0000_0000] = 1
462 m["asdf"] = 1
465 m = Google::Protobuf::Map.new(:uint32, :int32)
466 m[0x8000_0000] = 1
468 m[0x1_0000_0000] = 1
471 m[-1] = 1
474 m = Google::Protobuf::Map.new(:uint64, :int32)
475 m[0x8000_0000_0000_0000] = 1
477 m[0x1_0000_0000_0000_0000] = 1
480 m[-1] = 1
483 m = Google::Protobuf::Map.new(:bool, :int32)
484 m[true] = 1
485 m[false] = 2
487 m[1] = 1
490 m["asdf"] = 1
493 m = Google::Protobuf::Map.new(:string, :int32)
494 m["asdf"] = 1
496 m[1] = 1
500 m[bytestring] = 1
503 m = Google::Protobuf::Map.new(:bytes, :int32)
505 m[bytestring] = 1
507 m["asdf"] = 1
509 m[1] = 1
514 m = Google::Protobuf::Map.new(:string, :message, proto_module::TestMessage)
515 m["asdf"] = proto_module::TestMessage.new
517 m["jkl;"] = proto_module::TestMessage2.new
520 m = Google::Protobuf::Map.new(
524 assert m.length == 2
525 assert m.values.map{|msg| msg.optional_int32}.sort == [42, 84]
527 m = Google::Protobuf::Map.new(:string, :enum, proto_module::TestEnum,
529 assert m.length == 3
530 assert m["z"] == :C
531 m["z"] = 2
532 assert m["z"] == :B
533 m["z"] = 4
534 assert m["z"] == 4
536 m["z"] = :Z
539 m["z"] = "z"
544 m = Google::Protobuf::Map.new(
549 m2 = m.dup
550 assert m == m2
551 assert m.object_id != m2.object_id
552 assert m["a"].object_id == m2["a"].object_id
553 assert m["b"].object_id == m2["b"].object_id
555 m2 = Google::Protobuf.deep_copy(m)
556 assert m == m2
557 assert m.object_id != m2.object_id
558 assert m["a"].object_id != m2["a"].object_id
559 assert m["b"].object_id != m2["b"].object_id
648 m = proto_module::TestMessage.new
649 assert m.optional_enum == :Default
650 m.optional_enum = :A
651 assert m.optional_enum == :A
653 m.optional_enum = :ASDF
655 m.optional_enum = 1
656 assert m.optional_enum == :A
657 m.optional_enum = 100
658 assert m.optional_enum == 100
662 m = proto_module::TestMessage.new
663 m.optional_string = "hello"
664 m.optional_int32 = 42
667 m.repeated_msg.push tm1
668 assert m.repeated_msg[-1] == tm1
669 m.repeated_msg.push tm2
670 assert m.repeated_msg[-1] == tm2
671 m2 = m.dup
672 assert m == m2
673 m.optional_int32 += 1
674 assert m != m2
675 assert m.repeated_msg[0] == m2.repeated_msg[0]
676 assert m.repeated_msg[0].object_id == m2.repeated_msg[0].object_id
680 m = proto_module::TestMessage.new(:optional_int32 => 42,
682 m2 = Google::Protobuf.deep_copy(m)
683 assert m == m2
684 assert m.repeated_msg == m2.repeated_msg
685 assert m.repeated_msg.object_id != m2.repeated_msg.object_id
686 assert m.repeated_msg[0].object_id != m2.repeated_msg[0].object_id
690 m = proto_module::TestMessage.new(:optional_int32 => 42,
694 assert m != m2
712 m = proto_module::TestMessage.new
713 assert_equal proto_module::TestEnum::Default, m.optional_enum_const
714 assert_equal proto_module::TestEnum.const_get(:Default), m.optional_enum_const
716 m = proto_module::TestMessage.new({optional_enum: proto_module::TestEnum::A})
717 assert_equal proto_module::TestEnum::A, m.optional_enum_const
718 assert_equal proto_module::TestEnum.const_get(:A), m.optional_enum_const
720 m = proto_module::TestMessage.new({optional_enum: proto_module::TestEnum::B})
721 assert_equal proto_module::TestEnum::B, m.optional_enum_const
722 assert_equal proto_module::TestEnum.const_get(:B), m.optional_enum_const
724 m = proto_module::TestMessage.new({optional_enum: proto_module::TestEnum::C})
725 assert_equal proto_module::TestEnum::C, m.optional_enum_const
726 assert_equal proto_module::TestEnum.const_get(:C), m.optional_enum_const
728 m = proto_module::TestMessage2.new({foo: 2})
729 assert_equal 2, m.foo
730 assert_raise(NoMethodError) { m.foo_ }
731 assert_raise(NoMethodError) { m.foo_X }
732 assert_raise(NoMethodError) { m.foo_XX }
733 assert_raise(NoMethodError) { m.foo_XXX }
734 assert_raise(NoMethodError) { m.foo_XXXX }
735 assert_raise(NoMethodError) { m.foo_XXXXX }
736 assert_raise(NoMethodError) { m.foo_XXXXXX }
738 m = proto_module::Enumer.new({optional_enum: :B})
739 assert_equal :B, m.optional_enum
740 assert_raise(NoMethodError) { m.optional_enum_ }
741 assert_raise(NoMethodError) { m.optional_enum_X }
742 assert_raise(NoMethodError) { m.optional_enum_XX }
743 assert_raise(NoMethodError) { m.optional_enum_XXX }
744 assert_raise(NoMethodError) { m.optional_enum_XXXX }
745 assert_raise(NoMethodError) { m.optional_enum_XXXXX }
746 assert_raise(NoMethodError) { m.optional_enum_XXXXXX }
750 m = proto_module::Enumer.new(:optional_enum => :B, :repeated_enum => [:A, :C])
752 assert_equal :B, m.optional_enum
753 assert_equal 2, m.optional_enum_const
754 assert_equal proto_module::TestEnum::B, m.optional_enum_const
755 assert_equal [:A, :C], m.repeated_enum
756 assert_equal [1, 3], m.repeated_enum_const
757 assert_equal [proto_module::TestEnum::A, proto_module::TestEnum::C], m.repeated_enum_const
761 m = proto_module::Enumer.new(:const => :C)
763 assert_equal :C, m.const
764 assert_equal 3, m.const_const
765 assert_equal proto_module::TestEnum::C, m.const_const
769 m = proto_module::Enumer.new(:optional_enum => :B, :a_const => 'thing')
771 assert_equal 'thing', m.a_const
772 assert_equal :B, m.optional_enum
774 assert_raise(NoMethodError) { m.a }
775 assert_raise(NoMethodError) { m.a_const_const }
779 m = proto_module::TestMessage.new
781 m.repeated_string += ['one']
782 m.repeated_string += %w[two three]
783 assert_equal %w[one two three], m.repeated_string
785 m.repeated_string.push *['four', 'five']
786 assert_equal %w[one two three four five], m.repeated_string
788 m.repeated_string.push 'six', 'seven'
789 assert_equal %w[one two three four five six seven], m.repeated_string
791 m = proto_module::TestMessage.new
793 …m.repeated_msg += [proto_module::TestMessage2.new(:foo => 1), proto_module::TestMessage2.new(:foo …
794 m.repeated_msg += [proto_module::TestMessage2.new(:foo => 3)]
795 …m.repeated_msg.push proto_module::TestMessage2.new(:foo => 4), proto_module::TestMessage2.new(:foo…
796 assert_equal [1, 2, 3, 4, 5], m.repeated_msg.map {|x| x.foo}
800 m = proto_module::TestMessage.new(:optional_int32 => 42,
808 data = proto_module::TestMessage.encode m
810 assert m == m2
812 data = Google::Protobuf.encode m
814 assert m == m2
818 … m = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2'])
819 assert_equal 'foo', m.optional_string
820 assert_equal ['bar1', 'bar2'], m.repeated_string
822 json = m.to_json
831 proto = m.to_proto
838 … m = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2'])
839 encoded_msg = Google::Protobuf.encode(m)
840 assert_equal m.to_proto, encoded_msg
843 assert_equal proto_module::TestMessage.decode(m.to_proto), decoded_msg
847 … m = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2'])
848 encoded_msg = Google::Protobuf.encode_json(m)
849 assert_equal m.to_json, encoded_msg
852 assert_equal proto_module::TestMessage.decode_json(m.to_json), decoded_msg
878 …m = proto_module::Recursive1.new(:foo => proto_module::Recursive2.new(:foo => proto_module::Recurs…
884 serialized = proto_module::Recursive1.encode(m)
886 assert m == m2
890 m = proto_module::Recursive1.new(:foo => proto_module::Recursive2.new)
891 m.foo.foo = m
893 proto_module::Recursive1.encode(m)
898 m = proto_module::BadFieldNames.new(:dup => 1, :class => 2)
899 m2 = m.dup
900 assert m == m2
901 assert m['dup'] == 1
902 assert m['class'] == 2
903 m['dup'] = 3
904 assert m['dup'] == 3
905 m['a.b'] = 4
906 assert m['a.b'] == 4
910 m = proto_module::TestMessage.new
912 m.optional_int32 = 0
913 m.optional_int32 = -0x8000_0000
914 m.optional_int32 = +0x7fff_ffff
915 m.optional_int32 = 1.0
916 m.optional_int32 = -1.0
917 m.optional_int32 = 2e9
919 m.optional_int32 = -0x8000_0001
922 m.optional_int32 = +0x8000_0000
925 m.optional_int32 = +0x1000_0000_0000_0000_0000_0000 # force Bignum
928 m.optional_int32 = 1e12
931 m.optional_int32 = 1.5
934 m.optional_uint32 = 0
935 m.optional_uint32 = +0xffff_ffff
936 m.optional_uint32 = 1.0
937 m.optional_uint32 = 4e9
939 m.optional_uint32 = -1
942 m.optional_uint32 = -1.5
945 m.optional_uint32 = -1.5e12
948 m.optional_uint32 = -0x1000_0000_0000_0000
951 m.optional_uint32 = +0x1_0000_0000
954 m.optional_uint32 = +0x1000_0000_0000_0000_0000_0000 # force Bignum
957 m.optional_uint32 = 1e12
960 m.optional_uint32 = 1.5
963 m.optional_int64 = 0
964 m.optional_int64 = -0x8000_0000_0000_0000
965 m.optional_int64 = +0x7fff_ffff_ffff_ffff
966 m.optional_int64 = 1.0
967 m.optional_int64 = -1.0
968 m.optional_int64 = 8e18
969 m.optional_int64 = -8e18
971 m.optional_int64 = -0x8000_0000_0000_0001
974 m.optional_int64 = +0x8000_0000_0000_0000
977 m.optional_int64 = +0x1000_0000_0000_0000_0000_0000 # force Bignum
980 m.optional_int64 = 1e50
983 m.optional_int64 = 1.5
986 m.optional_uint64 = 0
987 m.optional_uint64 = +0xffff_ffff_ffff_ffff
988 m.optional_uint64 = 1.0
989 m.optional_uint64 = 16e18
991 m.optional_uint64 = -1
994 m.optional_uint64 = -1.5
997 m.optional_uint64 = -1.5e12
1000 m.optional_uint64 = -0x1_0000_0000_0000_0000
1003 m.optional_uint64 = +0x1_0000_0000_0000_0000
1006 m.optional_uint64 = +0x1000_0000_0000_0000_0000_0000 # force Bignum
1009 m.optional_uint64 = 1e50
1012 m.optional_uint64 = 1.5
1017 m = proto_module::TestMessage.new
1018 m.optional_int32 = 42
1019 m.optional_int64 = 0x100000000
1020 m.optional_string = "hello world"
1021 10.times do m.repeated_msg.push proto_module::TestMessage2.new(:foo => 42) end
1022 10.times do m.repeated_string.push "hello world" end
1024 data = proto_module::TestMessage.encode(m)
1027 m = proto_module::TestMessage.decode(data)
1028 data_new = proto_module::TestMessage.encode(m)
1035 m = proto_module::TestMessage.new(:optional_int32 => 1234)
1036 msgdef = m.class.descriptor
1044 optional_int32.set(m, 5678)
1045 assert m.optional_int32 == 5678
1046 m.optional_int32 = 1000
1047 assert optional_int32.get(m) == 1000
1052 optional_msg.set(m, optional_msg.subtype.msgclass.new)
1061 optional_enum.set(m, v)
1062 assert optional_enum.get(m) == k
1069 m = proto_module::TestMessage.new(:optional_int32 => 1234,
1085 json_text = proto_module::TestMessage.encode_json(m)
1087 puts m.inspect
1089 assert m == m2
1107 m = proto_module::TestMessage.new
1133 actual = proto_module::TestMessage.encode_json(m, :emit_defaults => true)
1141 m = proto_module::TestMessage.new(optional_msg: proto_module::TestMessage2.new)
1168 actual = proto_module::TestMessage.encode_json(m, :emit_defaults => true)
1176 m = proto_module::TestMessage.new(repeated_msg: [proto_module::TestMessage2.new])
1202 actual = proto_module::TestMessage.encode_json(m, :emit_defaults => true)
1273 m = proto_module::Wrapper.new(
1286 assert_equal 2.0, m.double_as_value
1287 assert_equal 2.0, m.double.value
1288 assert_equal 4.0, m.float_as_value
1289 assert_equal 4.0, m.float.value
1290 assert_equal 3, m.int32_as_value
1291 assert_equal 3, m.int32.value
1292 assert_equal 4, m.int64_as_value
1293 assert_equal 4, m.int64.value
1294 assert_equal 5, m.uint32_as_value
1295 assert_equal 5, m.uint32.value
1296 assert_equal 6, m.uint64_as_value
1297 assert_equal 6, m.uint64.value
1298 assert_equal true, m.bool_as_value
1299 assert_equal true, m.bool.value
1300 assert_equal 'str', m.string_as_value
1301 assert_equal 'str', m.string.value
1302 assert_equal 'fun', m.bytes_as_value
1303 assert_equal 'fun', m.bytes.value
1307 m = proto_module::Wrapper.new
1309 m.double_as_value = 4.8
1310 assert_equal 4.8, m.double_as_value
1311 assert_equal Google::Protobuf::DoubleValue.new(value: 4.8), m.double
1312 m.float_as_value = 2.4
1313 assert_in_delta 2.4, m.float_as_value
1314 assert_in_delta Google::Protobuf::FloatValue.new(value: 2.4).value, m.float.value
1315 m.int32_as_value = 5
1316 assert_equal 5, m.int32_as_value
1317 assert_equal Google::Protobuf::Int32Value.new(value: 5), m.int32
1318 m.int64_as_value = 15
1319 assert_equal 15, m.int64_as_value
1320 assert_equal Google::Protobuf::Int64Value.new(value: 15), m.int64
1321 m.uint32_as_value = 50
1322 assert_equal 50, m.uint32_as_value
1323 assert_equal Google::Protobuf::UInt32Value.new(value: 50), m.uint32
1324 m.uint64_as_value = 500
1325 assert_equal 500, m.uint64_as_value
1326 assert_equal Google::Protobuf::UInt64Value.new(value: 500), m.uint64
1327 m.bool_as_value = false
1328 assert_equal false, m.bool_as_value
1329 assert_equal Google::Protobuf::BoolValue.new(value: false), m.bool
1330 m.string_as_value = 'xy'
1331 assert_equal 'xy', m.string_as_value
1332 assert_equal Google::Protobuf::StringValue.new(value: 'xy'), m.string
1333 m.bytes_as_value = '123'
1334 assert_equal '123', m.bytes_as_value
1335 assert_equal Google::Protobuf::BytesValue.new(value: '123'), m.bytes
1337 m.double_as_value = nil
1338 assert_nil m.double
1339 assert_nil m.double_as_value
1340 m.float_as_value = nil
1341 assert_nil m.float
1342 assert_nil m.float_as_value
1343 m.int32_as_value = nil
1344 assert_nil m.int32
1345 assert_nil m.int32_as_value
1346 m.int64_as_value = nil
1347 assert_nil m.int64
1348 assert_nil m.int64_as_value
1349 m.uint32_as_value = nil
1350 assert_nil m.uint32
1351 assert_nil m.uint32_as_value
1352 m.uint64_as_value = nil
1353 assert_nil m.uint64
1354 assert_nil m.uint64_as_value
1355 m.bool_as_value = nil
1356 assert_nil m.bool
1357 assert_nil m.bool_as_value
1358 m.string_as_value = nil
1359 assert_nil m.string
1360 assert_nil m.string_as_value
1361 m.bytes_as_value = nil
1362 assert_nil m.bytes
1363 assert_nil m.bytes_as_value
1367 m = proto_module::Wrapper.new
1369 m.double = Google::Protobuf::DoubleValue.new(value: 4.8)
1370 assert_equal 4.8, m.double_as_value
1371 assert_equal Google::Protobuf::DoubleValue.new(value: 4.8), m.double
1372 m.float = Google::Protobuf::FloatValue.new(value: 2.4)
1373 assert_in_delta 2.4, m.float_as_value
1374 assert_in_delta Google::Protobuf::FloatValue.new(value: 2.4).value, m.float.value
1375 m.int32 = Google::Protobuf::Int32Value.new(value: 5)
1376 assert_equal 5, m.int32_as_value
1377 assert_equal Google::Protobuf::Int32Value.new(value: 5), m.int32
1378 m.int64 = Google::Protobuf::Int64Value.new(value: 15)
1379 assert_equal 15, m.int64_as_value
1380 assert_equal Google::Protobuf::Int64Value.new(value: 15), m.int64
1381 m.uint32 = Google::Protobuf::UInt32Value.new(value: 50)
1382 assert_equal 50, m.uint32_as_value
1383 assert_equal Google::Protobuf::UInt32Value.new(value: 50), m.uint32
1384 m.uint64 = Google::Protobuf::UInt64Value.new(value: 500)
1385 assert_equal 500, m.uint64_as_value
1386 assert_equal Google::Protobuf::UInt64Value.new(value: 500), m.uint64
1387 m.bool = Google::Protobuf::BoolValue.new(value: false)
1388 assert_equal false, m.bool_as_value
1389 assert_equal Google::Protobuf::BoolValue.new(value: false), m.bool
1390 m.string = Google::Protobuf::StringValue.new(value: 'xy')
1391 assert_equal 'xy', m.string_as_value
1392 assert_equal Google::Protobuf::StringValue.new(value: 'xy'), m.string
1393 m.bytes = Google::Protobuf::BytesValue.new(value: '123')
1394 assert_equal '123', m.bytes_as_value
1395 assert_equal Google::Protobuf::BytesValue.new(value: '123'), m.bytes
1397 m.double = nil
1398 assert_nil m.double
1399 assert_nil m.double_as_value
1400 m.float = nil
1401 assert_nil m.float
1402 assert_nil m.float_as_value
1403 m.int32 = nil
1404 assert_nil m.int32
1405 assert_nil m.int32_as_value
1406 m.int64 = nil
1407 assert_nil m.int64
1408 assert_nil m.int64_as_value
1409 m.uint32 = nil
1410 assert_nil m.uint32
1411 assert_nil m.uint32_as_value
1412 m.uint64 = nil
1413 assert_nil m.uint64
1414 assert_nil m.uint64_as_value
1415 m.bool = nil
1416 assert_nil m.bool
1417 assert_nil m.bool_as_value
1418 m.string = nil
1419 assert_nil m.string
1420 assert_nil m.string_as_value
1421 m.bytes = nil
1422 assert_nil m.bytes
1423 assert_nil m.bytes_as_value
1427 m = proto_module::Wrapper.new(real_string: 'hi', oneof_string: 'there')
1429 assert_raise(NoMethodError) { m.real_string_as_value }
1430 assert_raise(NoMethodError) { m.as_value }
1431 assert_raise(NoMethodError) { m._as_value }
1432 assert_raise(NoMethodError) { m.oneof_string_as_value }
1434 m = proto_module::Wrapper.new
1435 m.string_as_value = 'you'
1436 assert_equal 'you', m.string.value
1437 assert_equal 'you', m.string_as_value
1438 assert_raise(NoMethodError) { m.string_ }
1439 assert_raise(NoMethodError) { m.string_X }
1440 assert_raise(NoMethodError) { m.string_XX }
1441 assert_raise(NoMethodError) { m.string_XXX }
1442 assert_raise(NoMethodError) { m.string_XXXX }
1443 assert_raise(NoMethodError) { m.string_XXXXX }
1444 assert_raise(NoMethodError) { m.string_XXXXXX }
1445 assert_raise(NoMethodError) { m.string_XXXXXXX }
1446 assert_raise(NoMethodError) { m.string_XXXXXXXX }
1447 assert_raise(NoMethodError) { m.string_XXXXXXXXX }
1448 assert_raise(NoMethodError) { m.string_XXXXXXXXXX }
1452 m = proto_module::TimeMessage.new
1454 m.timestamp = Google::Protobuf::Timestamp.new(seconds: 5, nanos: 6)
1455 assert_kind_of Google::Protobuf::Timestamp, m.timestamp
1456 assert_equal 5, m.timestamp.seconds
1457 assert_equal 6, m.timestamp.nanos
1459 m.timestamp = Time.at(9466, 123456.789)
1460 assert_equal Google::Protobuf::Timestamp.new(seconds: 9466, nanos: 123456789), m.timestamp
1462 m = proto_module::TimeMessage.new(timestamp: Time.at(1))
1463 assert_equal Google::Protobuf::Timestamp.new(seconds: 1, nanos: 0), m.timestamp
1465 assert_raise(Google::Protobuf::TypeError) { m.timestamp = 2 }
1466 assert_raise(Google::Protobuf::TypeError) { m.timestamp = 2.4 }
1467 assert_raise(Google::Protobuf::TypeError) { m.timestamp = '4' }
1468 assert_raise(Google::Protobuf::TypeError) { m.timestamp = proto_module::TimeMessage.new }
1472 m = proto_module::TimeMessage.new
1474 m.duration = Google::Protobuf::Duration.new(seconds: 2, nanos: 22)
1475 assert_kind_of Google::Protobuf::Duration, m.duration
1476 assert_equal 2, m.duration.seconds
1477 assert_equal 22, m.duration.nanos
1479 m.duration = 10.5
1480 assert_equal Google::Protobuf::Duration.new(seconds: 10, nanos: 500_000_000), m.duration
1482 m.duration = 200
1483 assert_equal Google::Protobuf::Duration.new(seconds: 200, nanos: 0), m.duration
1485 m.duration = Rational(3, 2)
1486 assert_equal Google::Protobuf::Duration.new(seconds: 1, nanos: 500_000_000), m.duration
1488 m.duration = BigDecimal.new("5")
1489 assert_equal Google::Protobuf::Duration.new(seconds: 5, nanos: 0), m.duration
1491 m = proto_module::TimeMessage.new(duration: 1.1)
1492 assert_equal Google::Protobuf::Duration.new(seconds: 1, nanos: 100_000_000), m.duration
1494 assert_raise(Google::Protobuf::TypeError) { m.duration = '2' }
1495 assert_raise(Google::Protobuf::TypeError) { m.duration = proto_module::TimeMessage.new }
1499 m = proto_module::TestMessage.new
1500 m.optional_int32 = 10
1501 m.freeze
1503 frozen_error = assert_raise(FrozenErrorType) { m.optional_int32 = 20 }
1505 assert_equal 10, m.optional_int32
1506 assert_equal true, m.frozen?
1508 assert_raise(FrozenErrorType) { m.optional_int64 = 2 }
1509 assert_raise(FrozenErrorType) { m.optional_uint32 = 3 }
1510 assert_raise(FrozenErrorType) { m.optional_uint64 = 4 }
1511 assert_raise(FrozenErrorType) { m.optional_bool = true }
1512 assert_raise(FrozenErrorType) { m.optional_float = 6.0 }
1513 assert_raise(FrozenErrorType) { m.optional_double = 7.0 }
1514 assert_raise(FrozenErrorType) { m.optional_string = '8' }
1515 assert_raise(FrozenErrorType) { m.optional_bytes = nil }
1516 assert_raise(FrozenErrorType) { m.optional_msg = proto_module::TestMessage2.new }
1517 assert_raise(FrozenErrorType) { m.optional_enum = :A }
1518 assert_raise(FrozenErrorType) { m.repeated_int32 = 1 }
1519 assert_raise(FrozenErrorType) { m.repeated_int64 = 2 }
1520 assert_raise(FrozenErrorType) { m.repeated_uint32 = 3 }
1521 assert_raise(FrozenErrorType) { m.repeated_uint64 = 4 }
1522 assert_raise(FrozenErrorType) { m.repeated_bool = true }
1523 assert_raise(FrozenErrorType) { m.repeated_float = 6.0 }
1524 assert_raise(FrozenErrorType) { m.repeated_double = 7.0 }
1525 assert_raise(FrozenErrorType) { m.repeated_string = '8' }
1526 assert_raise(FrozenErrorType) { m.repeated_bytes = nil }
1527 assert_raise(FrozenErrorType) { m.repeated_msg = proto_module::TestMessage2.new }
1528 assert_raise(FrozenErrorType) { m.repeated_enum = :A }