Sha256: 2cf92c8319114cbbc6797ad609a12779dd618ba69e955e2cca10d98d94a9c661

Contents?: true

Size: 993 Bytes

Versions: 56

Compression:

Stored size: 993 Bytes

Contents

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

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
backlog-0.0.0 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.0.1 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.0.2 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.0.4 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.0.5 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.1.0 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.1.1 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.1.2 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.2.0 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.2.1 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.0 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.2 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.3 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.1 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.4 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.6 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.5 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.7 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.8 vendor/rails/activesupport/test/json/decoding_test.rb
backlog-0.3.9 vendor/rails/activesupport/test/json/decoding_test.rb