summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNARUSE, Yui <nurse@users.noreply.github.com>2020-07-31 11:06:58 +0900
committerGitHub <noreply@github.com>2020-07-31 11:06:58 +0900
commit8e081fb05c5054fa575dc9852ec1d599707376c9 (patch)
tree59914b3a3f83ca424174ba8ff9e211592d1e60d2 /tests
parente7cf232fa71b3a21094497d18c09ee7f24248bc3 (diff)
parent8a18cf6a14fc1fae54b3d581434a255c9d98ceea (diff)
downloadjson-8e081fb05c5054fa575dc9852ec1d599707376c9.tar.gz
Merge pull request #405 from Shopify/escape-slash-2.3.0
Add an option to escape forward slash character
Diffstat (limited to 'tests')
-rwxr-xr-x[-rw-r--r--]tests/json_generator_test.rb7
-rw-r--r--tests/json_parser_test.rb4
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/json_generator_test.rb b/tests/json_generator_test.rb
index 028f82f..77b539d 100644..100755
--- a/tests/json_generator_test.rb
+++ b/tests/json_generator_test.rb
@@ -173,6 +173,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => " ",
:max_nesting => 100,
:object_nl => "\n",
@@ -189,6 +190,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => "",
:max_nesting => 100,
:object_nl => "",
@@ -205,6 +207,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => "",
:max_nesting => 0,
:object_nl => "",
@@ -393,6 +396,10 @@ EOT
json = '["/"]'
assert_equal json, generate(data)
#
+ data = [ '/' ]
+ json = '["\/"]'
+ assert_equal json, generate(data, :escape_slash => true)
+ #
data = ['"']
json = '["\""]'
assert_equal json, generate(data)
diff --git a/tests/json_parser_test.rb b/tests/json_parser_test.rb
index 9946dd9..514441e 100644
--- a/tests/json_parser_test.rb
+++ b/tests/json_parser_test.rb
@@ -293,6 +293,10 @@ EOT
json = '["\\\'"]'
data = ["'"]
assert_equal data, parse(json)
+
+ json = '["\/"]'
+ data = [ '/' ]
+ assert_equal data, parse(json)
end
class SubArray < Array