summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorScott Myron <samyron@gmail.com>2026-01-15 19:12:41 -0600
committergit <svn-admin@ruby-lang.org>2026-01-16 17:52:54 +0000
commit456ef9140acbdf643c5537ee0f5d67429f2332b6 (patch)
tree10b5fd00f24348f78c8b0fdc4147d04fe10d918a /test
parentbc6c895d7bce16871321fcb22147a2d35179caaf (diff)
[ruby/json] Use __builtin_memcpy, if available, to copy overlapping byte ranges in copy_remaining_bytes to avoid a branch to MEMCPY. Additionally use a space as padding byte instead of an 'X' so it can be represented diretly on AArch64 with a single instruction.
https://github.com/ruby/json/commit/643ee11fed
Diffstat (limited to 'test')
-rwxr-xr-xtest/json/json_generator_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb
index 9f8b35de09..d7c4173e8e 100755
--- a/test/json/json_generator_test.rb
+++ b/test/json/json_generator_test.rb
@@ -650,6 +650,22 @@ class JSONGeneratorTest < Test::Unit::TestCase
json = '"\\nabc"'
assert_equal json, generate(data)
#
+ data = "\n"
+ json = '"\\n"'
+ assert_equal json, generate(data)
+ #
+ (0..16).each do |i|
+ data = ('a' * i) + "\n"
+ json = '"' + ('a' * i) + '\\n"'
+ assert_equal json, generate(data)
+ end
+ #
+ (0..16).each do |i|
+ data = "\n" + ('a' * i)
+ json = '"' + '\\n' + ('a' * i) + '"'
+ assert_equal json, generate(data)
+ end
+ #
data = ["'"]
json = '["\\\'"]'
assert_equal '["\'"]', generate(data)