summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-01-30 12:48:05 +0100
committerJean Boussier <jean.boussier@gmail.com>2020-07-04 12:14:47 +0200
commit8a18cf6a14fc1fae54b3d581434a255c9d98ceea (patch)
tree059a4f393a91df8506b4212e5158282fe1b07402 /tests
parent617428650d48db8a4b5439968e441f859605c6f3 (diff)
downloadjson-8a18cf6a14fc1fae54b3d581434a255c9d98ceea.tar.gz
Add an option to escape forward slash character
Squashed commit of the following: commit 26d181059989279a79c433cedcd893b4f52e42ee Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Tue Sep 15 21:17:34 2015 +0000 add config options for escape_slash commit fa282334051b16df91ca097dd7304b46f3bc7719 Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Mon Feb 9 21:09:33 2015 +0000 add forward slash to escape 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 ee19fa5..13d3b5a 100644..100755
--- a/tests/json_generator_test.rb
+++ b/tests/json_generator_test.rb
@@ -174,6 +174,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => " ",
:max_nesting => 100,
:object_nl => "\n",
@@ -190,6 +191,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => "",
:max_nesting => 100,
:object_nl => "",
@@ -206,6 +208,7 @@ EOT
:ascii_only => false,
:buffer_initial_length => 1024,
:depth => 0,
+ :escape_slash => false,
:indent => "",
:max_nesting => 0,
:object_nl => "",
@@ -394,6 +397,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