This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/tests/base/test_json.lua

33 lines
771 B
Lua
Raw Permalink Normal View History

2017-04-04 16:02:59 +00:00
--
-- tests/base/test_json.lua
-- Tests the json API
-- Copyright (c) 2017 Jason Perkins and the Premake project
--
local p = premake
local suite = test.declare("premake_json")
function suite.json_encode()
local result = json.encode({foo = "bar"})
result = result:gsub('%s*', ''),
test.isequal(result, '{"foo":"bar"}')
end
function suite.json_decode()
local result = json.decode('{ "foo": "bar" }')
test.isequal(result, { foo = "bar" })
end
function suite.json_encode_error()
local result, err = json.encode({ fubar = function() end })
test.isnil(result)
test.isequal(type(err), "string")
end
function suite.json_decode_error()
local result, err = json.decode("fubar string")
test.isnil(result)
test.isequal(type(err), "string")
end