Skip to content

Commit 8be4b8e

Browse files
author
Cody Horton
committed
regression test for custom pretty generate
1 parent 3d741e8 commit 8be4b8e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/json/json_generator_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ def test_generate_pretty
122122
assert_equal '666', pretty_generate(666)
123123
end
124124

125+
def test_generate_pretty_custom
126+
state = State.new(:space_before => "<psb>", :space => "<ps>", :indent => "<pi>", :object_nl => "\n<po_nl>\n", :array_nl => "<pa_nl>")
127+
json = pretty_generate({1=>{}, 2=>['a','b'], 3=>4}, state)
128+
assert_equal(<<~'JSON'.chomp, json)
129+
{
130+
<po_nl>
131+
<pi>"1"<psb>:<ps>{},
132+
<po_nl>
133+
<pi>"2"<psb>:<ps>[<pa_nl><pi><pi>"a",<pa_nl><pi><pi>"b"<pa_nl><pi>],
134+
<po_nl>
135+
<pi>"3"<psb>:<ps>4
136+
<po_nl>
137+
}
138+
JSON
139+
end
140+
125141
def test_generate_custom
126142
state = State.new(:space_before => " ", :space => " ", :indent => "<i>", :object_nl => "\n", :array_nl => "<a_nl>")
127143
json = generate({1=>{2=>3,4=>[5,6]}}, state)

0 commit comments

Comments
 (0)