File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -443,6 +443,23 @@ def test_invalid_encoding_string
443443 "\x82 \xAC \xEF " . to_json
444444 end
445445 assert_includes error . message , "source sequence is illegal/malformed utf-8"
446+
447+ error = assert_raise ( JSON ::GeneratorError ) do
448+ JSON . dump ( "\x82 \xAC \xEF " )
449+ end
450+ assert_includes error . message , "source sequence is illegal/malformed utf-8"
451+
452+ # These pass on the pure-Ruby generator but not with the native extension
453+ # https://github.com/ruby/json/issues/634
454+ if defined? ( JSON ::Pure )
455+ assert_raise ( Encoding ::UndefinedConversionError ) do
456+ "\x82 \xAC \xEF " . b . to_json
457+ end
458+
459+ assert_raise ( Encoding ::UndefinedConversionError ) do
460+ JSON . dump ( "\x82 \xAC \xEF " . b )
461+ end
462+ end
446463 end
447464
448465 if defined? ( JSON ::Ext ::Generator ) and RUBY_PLATFORM != "java"
You can’t perform that action at this time.
0 commit comments