summaryrefslogtreecommitdiff
path: root/test/json/json_generator_test.rb
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-05-09 14:21:17 +0200
committerHiroshi SHIBATA <[email protected]>2024-10-08 14:10:05 +0900
commit8fdd3d0ed629b95caa76cea1a58d6def8eac910c (patch)
treeb87ca78dbd7aa9c8316e45f4e47695f332edec9c /test/json/json_generator_test.rb
parentea9d34082f8a5011377c61e8eb5c21c51fbfd4a8 (diff)
JSON::Pure fix strict mode
Followup: https://github.com/flori/json/pull/519 Fix: https://github.com/flori/json/issues/584
Diffstat (limited to 'test/json/json_generator_test.rb')
-rwxr-xr-xtest/json/json_generator_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb
index 19b4c7434f..afe436b20d 100755
--- a/test/json/json_generator_test.rb
+++ b/test/json/json_generator_test.rb
@@ -67,6 +67,25 @@ EOT
def test_dump_strict
assert_equal '{}', dump({}, strict: true)
+
+ assert_equal '{"array":[42,4.2,"forty-two",true,false,null]}', dump({
+ "array" => [42, 4.2, "forty-two", true, false, nil]
+ }, strict: true)
+
+ assert_equal '{"int":42,"float":4.2,"string":"forty-two","true":true,"false":false,"nil":null,"hash":{}}', dump({
+ "int" => 42,
+ "float" => 4.2,
+ "string" => "forty-two",
+ "true" => true,
+ "false" => false,
+ "nil" => nil,
+ "hash" => {},
+ }, strict: true)
+
+ assert_equal '[]', dump([], strict: true)
+
+ assert_equal '42', dump(42, strict: true)
+ assert_equal 'true', dump(true, strict: true)
end
def test_generate_pretty