local ScribuntoUnit = require('Modulo:ScribuntoUnit')

p = {}

--------------------------------------------------------------------------------
-- Test assertEquals

local function testAssertEquals(msg, expected, actual, shouldFail)
	local out = msg .. ' '
	local errmsg = ''

	success, details = pcall(function ()
		local suite = ScribuntoUnit:new()
		suite:assertEquals(expected, actual)
	end)
	
	if not success and (type(details) ~= 'table' or not details.ScribuntoUnit) then -- a real error, not a failed assertion
		errmsg = 'Lua errore: ' .. tostring(details)
	end
	
	if success == not shouldFail then
		out = out .. 'OK'
	else
		out = out .. 'FALLITO'	.. (errmsg and ' -- ' .. errmsg or '')			
	end

	return out
end
	
function p.testAssertEqualsWithEqualStrings()
	
	return testAssertEquals(
		'Verificare che la funzione assertEquals non genera errore per stringhe uguali...',
		'abc',
		'abc',
		false
	)

end

function p.testAssertEqualsWithUnequalStrings()
	
	return testAssertEquals(
		'Verificare che la funzione assertEquals genera errore per stringhe non uguali...',
		'abc',
		'def',
		true
	)

end

--------------------------------------------------------------------------------
-- TODO: Test more methods
--

return p