mirror of
https://github.com/TangentFoxy/semver.lua.git
synced 2025-07-28 02:52:21 +00:00
added more input checking
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user