Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lua/tests/gmod/unit/libraries/string/Left.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
return {
groupName = "string.Left",

cases = {
{
name = "Exists on the string table",
func = function()
expect( string.Left ).to.beA( "function" )
end
},

{
name = "Returns the expected string value",
func = function()
expect( string.Left( "Hello!", 1 ) ).to.equal( "H" )
expect( string.Left( "H", 1 ) ).to.equal( "H" )
expect( string.Left( "Hello!", 10 ) ).to.equal( "Hello!" )
expect( string.Left( nil ) ).to.errWith( [[bad argument #1 to 'Left' (string expected, got nil)]] )

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (public) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (public) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (dev) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (dev) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (prerelease) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (prerelease) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (x86-64) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Left.lua

View workflow job for this annotation

GitHub Actions / run_tests (x86-64) / Run tests

Unhandled: bad argument #1 to 'Left' (string expected, got nil)
expect( string.Left( nil, 1 ) ).to.errWith( [[bad argument #1 to 'Left' (string expected, got nil)]] )
expect( string.Left( "Hello!" ) ).to.equal( "Hello!" )
expect( string.Left( "Hello!", -1 ) ).to.equal( "Hello!" )
expect( string.Left( "Hello World!", -8 ) ).to.equal( "Hello" )
expect( string.Left( "garrys mod", 5 ) ).to.equal( "garry" )
end
}
}
}
27 changes: 27 additions & 0 deletions lua/tests/gmod/unit/libraries/string/Right.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
return {
groupName = "string.Right",

cases = {
{
name = "Exists on the string table",
func = function()
expect( string.Right ).to.beA( "function" )
end
},

{
name = "Returns the expected string value",
func = function()
expect( string.Right( "Hello!", 1 ) ).to.equal( "!" )
expect( string.Right( "H", 1 ) ).to.equal( "H" )
expect( string.Right( "Hello!", 10 ) ).to.equal( "Hello!" )
expect( string.Right( nil ) ).to.errWith( [[attempt to perform arithmetic on local 'num' (a nil value)]] )

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (public) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (public) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (dev) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (dev) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (prerelease) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (prerelease) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (x86-64) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)

Check failure on line 18 in lua/tests/gmod/unit/libraries/string/Right.lua

View workflow job for this annotation

GitHub Actions / run_tests (x86-64) / Run tests

Unhandled: attempt to perform arithmetic on local 'num' (a nil value)
expect( string.Right( nil, 1 ) ).to.errWith( [[bad argument #1 to 'Right' (string expected, got nil)]] )
expect( string.Right( "Hello!" ) ).to.errWith( [[attempt to perform arithmetic on local 'num' (a nil value)]] )
expect( string.Right( "Hello!", -1 ) ).to.equal( "Hello!" )
expect( string.Right( "Hello World!", -8 ) ).to.equal( "orld!" )
expect( string.Right( "garrys mod", 3 ) ).to.equal( "mod" )
end
}
}
}
Loading