diff options
author | Jean Boussier <[email protected]> | 2024-10-07 21:43:36 -0400 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-10-08 14:10:05 +0900 |
commit | 718c4f7e1e449f43b0c82bfd2826b3a14ac329df (patch) | |
tree | 1c696355eb3266d927f6d267404034f495d280c6 /test/json/json_generator_test.rb | |
parent | 8fdd3d0ed629b95caa76cea1a58d6def8eac910c (diff) |
JSONPure: String#to_json should raise on invalid encoding
Fix: #344
This matches the ext behavior.
Diffstat (limited to 'test/json/json_generator_test.rb')
-rwxr-xr-x | test/json/json_generator_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index afe436b20d..d09c6479fa 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -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 |