-
Notifications
You must be signed in to change notification settings - Fork 8
Add string.Left/string.Right #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e0eaf5c
5a9d095
1517764
462d80b
30e9590
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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
|
||
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 | ||
} | ||
} | ||
} |
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)]] ) | ||
expect( string.Right, nil, 1 ).to.errWith( [[bad argument #1 to 'Right' (string expected, got nil)]] ) | ||
Check failure on line 19 in lua/tests/gmod/unit/libraries/string/Right.lua
|
||
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 | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.