diff options
author | Jean Boussier <[email protected]> | 2024-10-24 16:04:50 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-11-01 13:04:24 +0900 |
commit | 3782600f0f4f2f70a4d17f025fde6c096f82b424 (patch) | |
tree | 8525ebd02821006520cdd9c1f22a59372a624eb3 /test/json/json_generator_test.rb | |
parent | f2b8829df0092409c944aafeac03f72ab2a6e7ac (diff) |
[ruby/json] Emit warnings when dumping binary strings
Because of it's Ruby 1.8 heritage, the C extension doesn't care
much about strings encoding. We should get stricter over time.
https://github.com/ruby/json/commit/42402fc13f
Diffstat (limited to 'test/json/json_generator_test.rb')
-rwxr-xr-x | test/json/json_generator_test.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index 2b1d48b61b..288cbbbb3a 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -507,8 +507,13 @@ class JSONGeneratorTest < Test::Unit::TestCase wrong_encoding_string = utf8_string.b # This behavior is historical. Not necessary desirable. We should deprecated it. # The pure and java version of the gem already don't behave this way. - assert_equal utf8_string.to_json, wrong_encoding_string.to_json - assert_equal JSON.dump(utf8_string), JSON.dump(wrong_encoding_string) + assert_warning(/UTF-8 string passed as BINARY, this will raise an encoding error in json 3.0/) do + assert_equal utf8_string.to_json, wrong_encoding_string.to_json + end + + assert_warning(/UTF-8 string passed as BINARY, this will raise an encoding error in json 3.0/) do + assert_equal JSON.dump(utf8_string), JSON.dump(wrong_encoding_string) + end end def test_string_ext_included_calls_super |