brew/Library/Homebrew/test/test_json.rb

21 lines
498 B
Ruby
Raw Normal View History

require "testing_env"
require "utils/json"
class JsonSmokeTest < Homebrew::TestCase
def test_encode
hash = { "foo" => ["bar", "baz"] }
json = '{"foo":["bar","baz"]}'
assert_equal json, Utils::JSON.dump(hash)
end
def test_decode
hash = { "foo" => ["bar", "baz"], "qux" => 1 }
json = '{"foo":["bar","baz"],"qux":1}'
assert_equal hash, Utils::JSON.load(json)
end
def test_decode_failure
assert_raises(Utils::JSON::Error) { Utils::JSON.load("nope") }
end
end