2015-08-03 13:09:07 +01:00
|
|
|
require "testing_env"
|
|
|
|
require "utils/json"
|
2013-01-14 22:32:37 -06:00
|
|
|
|
2014-06-18 20:32:51 -05:00
|
|
|
class JsonSmokeTest < Homebrew::TestCase
|
2013-01-14 22:32:37 -06:00
|
|
|
def test_encode
|
2013-01-17 22:25:29 -06:00
|
|
|
hash = { "foo" => ["bar", "baz"] }
|
2015-08-03 13:09:07 +01:00
|
|
|
json = '{"foo":["bar","baz"]}'
|
2013-06-22 16:51:08 -05:00
|
|
|
assert_equal json, Utils::JSON.dump(hash)
|
2013-01-14 22:32:37 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_decode
|
|
|
|
hash = { "foo" => ["bar", "baz"], "qux" => 1 }
|
2015-08-03 13:09:07 +01:00
|
|
|
json = '{"foo":["bar","baz"],"qux":1}'
|
2013-06-22 16:51:08 -05:00
|
|
|
assert_equal hash, Utils::JSON.load(json)
|
2013-01-14 22:32:37 -06:00
|
|
|
end
|
|
|
|
end
|