local p = require('Module:UnitTests')
local fds = require('Module:Ficha de software')

function test(name, builder, expected)
    p:equals(name, tostring(builder), tostring(expected))
end

function p:test_all()
	test_paddedcompare()
end

function test_paddedcompare()
	test("Padded compare: 12 > 9", fds._paddedcompare("12.0.0.0", "9.0.0.0"), true)
	test("Padded compare: 12.0 > 9.127", fds._paddedcompare("12.0.0", "9.127.0"), true)
	test("Padded compare: 12.0-7b1c > 9.127-7b1c", fds._paddedcompare("12.0.0-7b1c", "9.127.0-7b1c"), true)
	test("Padded compare: !(9 > 12)", fds._paddedcompare("9.0.0.0", "12.0.0.0"), false)
	test("Padded compare: !(9.127 > 12.0)", fds._paddedcompare("9.127.0", "12.0.0"), false)
	test("Padded compare: !(9.127-7b1c > 12.0-7b1c)", fds._paddedcompare("9.127.0-7b1c", "12.0.0-7b1c"), false)
	test("Padded compare: !(42.0 > 42.0.0)", fds._paddedcompare("42.0", "42.0.0"), false)
	test("Padded compare: !(42.0 > 42.0.1)", fds._paddedcompare("42.0", "42.0.0"), false)
end

return p