summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Mac-Vicar <mmacvicar@gmail.com>2014-12-07 15:17:17 -0200
committerFlorian Frank <flori@ping.de>2015-01-09 01:51:41 +0100
commit82babeccc5e155782586deef81b1a1d79851b1ed (patch)
tree7e72bb09a7fcd588f70f9407b02df69b28ba7d98 /tests
parentcfa8b00be6c4d41a701f0a1912a5c8fd3d08abc9 (diff)
downloadjson-82babeccc5e155782586deef81b1a1d79851b1ed.tar.gz
Add test for format options used by the generator
The space_before, space, indent, object_nl and array_nl options of the space were not covered.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_json_generate.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb
index ea6a9a3..ba05eeb 100755
--- a/tests/test_json_generate.rb
+++ b/tests/test_json_generate.rb
@@ -73,6 +73,19 @@ EOT
assert_equal '666', pretty_generate(666, :quirks_mode => true)
end
+ def test_generate_custom
+ state = State.new(space_before: " ", space: " ", indent:"<i>", object_nl: "\n", array_nl: "<a_nl>")
+ json = generate({1=>{2=>3,4=>[5,6]}}, state)
+ assert_equal(<<'EOT'.chomp, json)
+{
+<i>"1" : {
+<i><i>"2" : 3,
+<i><i>"4" : [<a_nl><i><i><i>5,<a_nl><i><i><i>6<a_nl><i><i>]
+<i>}
+}
+EOT
+ end
+
def test_fast_generate
json = fast_generate(@hash)
assert_equal(JSON.parse(@json2), JSON.parse(json))