From b19b4b7b2ac3b1521c99db2d07a6743ea43161fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 8 Sep 2025 14:50:18 +0200 Subject: [ruby/json] Change invalid encoding test to use assert_raise https://github.com/ruby/json/commit/efc61682ee Co-authored-by: Jean Boussier --- test/json/json_encoding_test.rb | 12 ++---------- 1 file 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 -- cgit v1.2.3