summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2010-08-07 01:18:56 +0200
committerFlorian Frank <flori@ping.de>2010-08-07 01:20:52 +0200
commit310c96b4134f8c0f5d63822a25ccdbc83c30e86e (patch)
tree8f8f34719090dc0d272ce564135f3f203ad5e0cb /tests
parentf8fcc04c9f1d5de3c035a71a507af5023a0406b0 (diff)
downloadjson-310c96b4134f8c0f5d63822a25ccdbc83c30e86e.tar.gz
added missing methods to State + tests
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_json_generate.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb
index 26ca1ad..8dc804b 100755
--- a/tests/test_json_generate.rb
+++ b/tests/test_json_generate.rb
@@ -102,6 +102,51 @@ EOT
assert s[:check_circular?]
end
+ def test_pretty_state
+ state = PRETTY_STATE_PROTOTYPE.dup
+ assert_equal({
+ :allow_nan => false,
+ :array_nl => "\n",
+ :ascii_only => false,
+ :depth => 0,
+ :indent => " ",
+ :max_nesting => 19,
+ :object_nl => "\n",
+ :space => " ",
+ :space_before => "",
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
+ end
+
+ def test_safe_state
+ state = SAFE_STATE_PROTOTYPE.dup
+ assert_equal({
+ :allow_nan => false,
+ :array_nl => "",
+ :ascii_only => false,
+ :depth => 0,
+ :indent => "",
+ :max_nesting => 19,
+ :object_nl => "",
+ :space => "",
+ :space_before => "",
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
+ end
+
+ def test_fast_state
+ state = FAST_STATE_PROTOTYPE.dup
+ assert_equal({
+ :allow_nan => false,
+ :array_nl => "",
+ :ascii_only => false,
+ :depth => 0,
+ :indent => "",
+ :max_nesting => 0,
+ :object_nl => "",
+ :space => "",
+ :space_before => "",
+ }.sort_by { |n,| n.to_s }, state.to_h.sort_by { |n,| n.to_s })
+ end
+
def test_allow_nan
assert_raises(GeneratorError) { generate([JSON::NaN]) }
assert_equal '[NaN]', generate([JSON::NaN], :allow_nan => true)