mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
3202fbabe6
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6443 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
28 lines
993 B
Ruby
28 lines
993 B
Ruby
require File.dirname(__FILE__) + '/../abstract_unit'
|
|
|
|
class TestJSONDecoding < Test::Unit::TestCase
|
|
TESTS = {
|
|
%({"returnTo":{"/categories":"/"}}) => {"returnTo" => {"/categories" => "/"}},
|
|
%({returnTo:{"/categories":"/"}}) => {"returnTo" => {"/categories" => "/"}},
|
|
%({"return\\"To\\":":{"/categories":"/"}}) => {"return\"To\":" => {"/categories" => "/"}},
|
|
%({"returnTo":{"/categories":1}}) => {"returnTo" => {"/categories" => 1}},
|
|
%({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]},
|
|
%({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]},
|
|
%([]) => [],
|
|
%({}) => {},
|
|
%(1) => 1,
|
|
%("") => "",
|
|
%("\\"") => "\"",
|
|
%(null) => nil,
|
|
%(true) => true,
|
|
%(false) => false
|
|
}
|
|
|
|
def test_json_decoding
|
|
TESTS.each do |json, expected|
|
|
assert_nothing_raised do
|
|
assert_equal expected, ActiveSupport::JSON.decode(json)
|
|
end
|
|
end
|
|
end
|
|
end
|