JSONPure: String#to_json should raise on invalid encoding

Fix: #344

This matches the ext behavior.
This commit is contained in:
Jean Boussier 2024-10-07 21:43:36 -04:00 committed by Hiroshi SHIBATA
parent 8fdd3d0ed6
commit 718c4f7e1e

View File

@ -438,6 +438,13 @@ EOT
end
end
def test_invalid_encoding_string
error = assert_raise(JSON::GeneratorError) do
"\x82\xAC\xEF".to_json
end
assert_includes error.message, "source sequence is illegal/malformed utf-8"
end
if defined?(JSON::Ext::Generator) and RUBY_PLATFORM != "java"
def test_string_ext_included_calls_super
included = false