mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-15 19:56:59 +08:00
21 lines
498 B
Ruby
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
|