summaryrefslogtreecommitdiff
path: root/test/json
diff options
context:
space:
mode:
Diffstat (limited to 'test/json')
-rw-r--r--test/json/test_json_generate.rb4
-rwxr-xr-xtest/json/test_json_unicode.rb12
2 files changed, 9 insertions, 7 deletions
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb
index 519d56a..82d8c3d 100644
--- a/test/json/test_json_generate.rb
+++ b/test/json/test_json_generate.rb
@@ -40,7 +40,7 @@ EOT
def test_unparse
json = unparse(@hash)
- assert_equal(@json2, json)
+ assert_equal(JSON.parse(@json2), JSON.parse(json))
parsed_json = parse(json)
assert_equal(@hash, parsed_json)
json = generate({1=>2})
@@ -51,7 +51,7 @@ EOT
def test_unparse_pretty
json = pretty_unparse(@hash)
- assert_equal(@json3, json)
+ assert_equal(JSON.parse(@json3), JSON.parse(json))
parsed_json = parse(json)
assert_equal(@hash, parsed_json)
json = pretty_generate({1=>2})
diff --git a/test/json/test_json_unicode.rb b/test/json/test_json_unicode.rb
index a23e50e..a91f4b5 100755
--- a/test/json/test_json_unicode.rb
+++ b/test/json/test_json_unicode.rb
@@ -39,15 +39,17 @@ class TC_JSONUnicode < Test::Unit::TestCase
def test_chars
(0..0x7f).each do |i|
- c = ('%c' % i)[0] # c is a character object
json = '["\u%04x"]' % i
- assert_equal c, JSON.parse(json).first
- if c == ?\b
+ if RUBY_VERSION >= "1.9."
+ i = i.chr
+ end
+ assert_equal i, JSON.parse(json).first[0]
+ if i == ?\b
generated = JSON.generate(["" << i])
assert '["\b"]' == generated || '["\10"]' == generated
- elsif [?\n, ?\r, ?\t, ?\f].include?(c)
+ elsif [?\n, ?\r, ?\t, ?\f].include?(i)
assert_equal '[' << ('' << i).dump << ']', JSON.generate(["" << i])
- elsif i < 0x20
+ elsif i.chr < 0x20.chr
assert_equal json, JSON.generate(["" << i])
end
end