diff options
| author | Étienne Barrié <etienne.barrie@gmail.com> | 2025-09-08 14:50:18 +0200 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2025-09-11 11:54:49 +0900 |
| commit | b19b4b7b2ac3b1521c99db2d07a6743ea43161fd (patch) | |
| tree | 9368b93de7e7f38604c3f5d91f1c3711b17acee3 | |
| parent | 3097a7bd125885ae4a3256542cd4d4aebd1d82da (diff) | |
[ruby/json] Change invalid encoding test to use assert_raise
https://github.com/ruby/json/commit/efc61682ee
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
| -rw-r--r-- | test/json/json_encoding_test.rb | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/test/json/json_encoding_test.rb b/test/json/json_encoding_test.rb index 873e96fddd..caf335d521 100644 --- a/test/json/json_encoding_test.rb +++ b/test/json/json_encoding_test.rb @@ -145,19 +145,11 @@ class JSONEncodingTest < Test::Unit::TestCase end def test_invalid_utf8_sequences - # Create strings with invalid UTF-8 sequences invalid_utf8 = "\xFF\xFF" - - # Test that generating JSON with invalid UTF-8 raises an error - # Different JSON implementations may handle this differently, - # so we'll check if any exception is raised - begin + error = assert_raise(JSON::GeneratorError) do generate(invalid_utf8) - raise "Expected an exception when generating JSON with invalid UTF8" - rescue StandardError => e - assert true - assert_match(%r{source sequence is illegal/malformed utf-8}, e.message) end + assert_match(%r{source sequence is illegal/malformed utf-8}, error.message) end def test_surrogate_pair_handling |
