summaryrefslogtreecommitdiff
path: root/trunk/test/json/test_json_generate.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
commitd0233291bc8a5068e52c69c210e5979e5324b5bc (patch)
tree7d9459449c33792c63eeb7baa071e76352e0baab /trunk/test/json/test_json_generate.rb
parent0dc342de848a642ecce8db697b8fecd83a63e117 (diff)
parent72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff)
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/test/json/test_json_generate.rb')
-rw-r--r--trunk/test/json/test_json_generate.rb80
1 files changed, 0 insertions, 80 deletions
diff --git a/trunk/test/json/test_json_generate.rb b/trunk/test/json/test_json_generate.rb
deleted file mode 100644
index e720b2d862..0000000000
--- a/trunk/test/json/test_json_generate.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'test/unit'
-require 'json'
-
-class TC_JSONGenerate < Test::Unit::TestCase
- include JSON
-
- def setup
- @hash = {
- 'a' => 2,
- 'b' => 3.141,
- 'c' => 'c',
- 'd' => [ 1, "b", 3.14 ],
- 'e' => { 'foo' => 'bar' },
- 'g' => "\"\0\037",
- 'h' => 1000.0,
- 'i' => 0.001
- }
- @json2 = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},' +
- '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}'
- @json3 = <<'EOT'.chomp
-{
- "a": 2,
- "b": 3.141,
- "c": "c",
- "d": [
- 1,
- "b",
- 3.14
- ],
- "e": {
- "foo": "bar"
- },
- "g": "\"\u0000\u001f",
- "h": 1000.0,
- "i": 0.001
-}
-EOT
- end
-
- def test_unparse
- json = unparse(@hash)
- assert_equal(JSON.parse(@json2), JSON.parse(json))
- parsed_json = parse(json)
- assert_equal(@hash, parsed_json)
- json = generate({1=>2})
- assert_equal('{"1":2}', json)
- parsed_json = parse(json)
- assert_equal({"1"=>2}, parsed_json)
- end
-
- def test_unparse_pretty
- json = pretty_unparse(@hash)
- assert_equal(JSON.parse(@json3), JSON.parse(json))
- parsed_json = parse(json)
- assert_equal(@hash, parsed_json)
- json = pretty_generate({1=>2})
- assert_equal(<<'EOT'.chomp, json)
-{
- "1": 2
-}
-EOT
- parsed_json = parse(json)
- assert_equal({"1"=>2}, parsed_json)
- end
-
- def test_states
- json = generate({1=>2}, nil)
- assert_equal('{"1":2}', json)
- s = JSON.state.new(:check_circular => true)
- #assert s.check_circular
- h = { 1=>2 }
- h[3] = h
- assert_raises(JSON::CircularDatastructure) { generate(h, s) }
- s = JSON.state.new(:check_circular => true)
- #assert s.check_circular
- a = [ 1, 2 ]
- a << a
- assert_raises(JSON::CircularDatastructure) { generate(a, s) }
- end
-end