Skip to content

Commit 0c096ac

Browse files
committed
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.
1 parent 17fe8e7 commit 0c096ac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_json_generate.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ def test_generate_pretty
7373
assert_equal '666', pretty_generate(666, :quirks_mode => true)
7474
end
7575

76+
def test_generate_custom
77+
state = State.new(space_before: " ", space: " ", indent:"<i>", object_nl: "\n", array_nl: "<a_nl>")
78+
json = generate({1=>{2=>3,4=>[5,6]}}, state)
79+
assert_equal(<<'EOT'.chomp, json)
80+
{
81+
<i>"1" : {
82+
<i><i>"2" : 3,
83+
<i><i>"4" : [<a_nl><i><i><i>5,<a_nl><i><i><i>6<a_nl><i><i>]
84+
<i>}
85+
}
86+
EOT
87+
end
88+
7689
def test_fast_generate
7790
json = fast_generate(@hash)
7891
assert_equal(JSON.parse(@json2), JSON.parse(json))

0 commit comments

Comments
 (0)