diff options
author | Michael Mac-Vicar <mmacvicar@gmail.com> | 2014-12-07 15:17:17 -0200 |
---|---|---|
committer | Michael Mac-Vicar <mmacvicar@gmail.com> | 2014-12-07 15:20:05 -0200 |
commit | 0c096ac8b9dae94d051439f98cbd6a21d2b1d212 (patch) | |
tree | 5fd6deab07afd80c67d0d9e1186264c1da2b993b | |
parent | 17fe8e72f484e65e0c36670946934d1f8696e37b (diff) | |
download | json-0c096ac8b9dae94d051439f98cbd6a21d2b1d212.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.
-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 117a155..a39e161 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)) |