@@ -38,36 +38,14 @@ def hex2bin(s)
38
38
39
39
class NonConformantNumericsTest < Test ::Unit ::TestCase
40
40
def test_empty_json_numerics
41
- if defined? JRUBY_VERSION and Google ::Protobuf ::IMPLEMENTATION != :FFI
42
- # In a future version, CRuby and JRuby FFI will also have this behavior.
43
- assert_raises Google ::Protobuf ::ParseError do
44
- msg = ::BasicTestProto2 ::TestMessage . decode_json ( '{"optionalInt32":""}' )
45
- end
46
- else
47
- warnings = CaptureWarnings . capture {
48
- msg = ::BasicTestProto2 ::TestMessage . decode_json ( '{"optionalInt32":""}' )
49
- assert_equal 0 , msg . optional_int32
50
- assert msg . has_optional_int32?
51
- }
52
- assert_equal 1 , warnings . size
53
- assert_match "Empty string is not a valid number (field: basic_test_proto2.TestMessage.optional_int32)" , warnings [ 0 ]
41
+ assert_raises Google ::Protobuf ::ParseError do
42
+ msg = ::BasicTestProto2 ::TestMessage . decode_json ( '{"optionalInt32":""}' )
54
43
end
55
44
end
56
45
57
46
def test_trailing_non_numeric_characters
58
- if defined? JRUBY_VERSION and Google ::Protobuf ::IMPLEMENTATION != :FFI
59
- # In a future version, CRuby and JRuby FFI will also have this behavior.
60
- assert_raises Google ::Protobuf ::ParseError do
61
- msg = ::BasicTestProto2 ::TestMessage . decode_json ( '{"optionalDouble":"123abc"}' )
62
- end
63
- else
64
- warnings = CaptureWarnings . capture {
65
- msg = ::BasicTestProto2 ::TestMessage . decode_json ( '{"optionalDouble":"123abc"}' )
66
- assert_equal 123 , msg . optional_double
67
- assert msg . has_optional_double?
68
- }
69
- assert_equal 1 , warnings . size
70
- assert_match "Non-number characters in quoted number (field: basic_test_proto2.TestMessage.optional_double)" , warnings [ 0 ]
47
+ assert_raises Google ::Protobuf ::ParseError do
48
+ msg = ::BasicTestProto2 ::TestMessage . decode_json ( '{"optionalDouble":"123abc"}' )
71
49
end
72
50
end
73
51
end
0 commit comments