brew/Library/Homebrew/test/test_json.rb
Baptiste Fontaine a6d2723ef5 more core unit tests
Closes Homebrew/homebrew#47182.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-12-20 12:11:40 +01:00

21 lines
498 B
Ruby

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