diff options
author | Michael Mac-Vicar <mmacvicar@gmail.com> | 2014-12-07 15:17:17 -0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2015-01-09 01:51:41 +0100 |
commit | 82babeccc5e155782586deef81b1a1d79851b1ed (patch) | |
tree | 7e72bb09a7fcd588f70f9407b02df69b28ba7d98 /tests | |
parent | cfa8b00be6c4d41a701f0a1912a5c8fd3d08abc9 (diff) | |
download | json-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-x | tests/test_json_generate.rb | 13 |
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)) |