Hopp til innhold

Bruker:Jeblad/Module:DKjson/testtilfeller

Fra Wikipedia, den frie encyklopedi
Sideversjon per 18. aug. 2015 kl. 20:33 av Jeblad (diskusjon | bidrag) (Ny side: -- Unit tests for Module:JSONstat. Click talk page to run tests. -- Note that the test set at Bruker:Jeblad/SSB01222.json is not live and only for test purposes. local p = requir...)
(diff) ← Eldre sideversjon | Nåværende sideversjon (diff) | Nyere sideversjon → (diff)


-- Unit tests for [[Module:JSONstat]]. Click talk page to run tests.
-- Note that the test set at [[Bruker:Jeblad/SSB01222.json]] is not live and only for test purposes.
local p = require('Module:UnitTests')
local dkjson = require('Module:DKjson')

local str =
[[{
  "numbers": [ 2, 3, -20.23e+2, -4 ],
  "currency": "\u20AC"
}]]

function p:test_json()
	local obj, pos, err = json.decode(str, 1, nil)
	self:equals( 'Should be no errors', err, nil )
	self:equals_deep( 'Should be similar table', obj.numbers, {2, 3, -20.23e+2, -4} )
	self:equals( 'Should be similar currency', obj.currency, "\u20AC" )
end

return p