added more input checking

This commit is contained in:
Enrique García Cota
2012-01-14 00:22:56 +01:00
parent e1f1b4898c
commit 912dd1d8ee
2 changed files with 24 additions and 5 deletions

View File

@@ -39,17 +39,27 @@ context('semver', function()
end)
end)
describe('errors', function()
it('throws an error if no parameters are passed', function()
describe('errors are thrown in', function()
test('no parameters are passed', function()
assert_error(function() v() end)
end)
it('throws an error on an empty string', function()
test('negative numbers', function()
assert_error(function() v(-1, 0, 0) end)
assert_error(function() v( 0,-1, 0) end)
assert_error(function() v( 0, 0,-1) end)
end)
test('floats', function()
assert_error(function() v(.1, 0, 0) end)
assert_error(function() v( 0,.1, 0) end)
assert_error(function() v( 0, 0,.1) end)
end)
test('empty string', function()
assert_error(function() v("") end)
end)
it('throws an error with garbage at the beginning of the string', function()
test('garbage at the beginning of the string', function()
assert_error(function() v("foobar1.2.3") end)
end)
it('throws an error with garbage at the end of the string', function()
test('garbage at the end of the string', function()
assert_error(function() v("1.2.3foobar") end)
end)
end)