rename expect.find to expect.str_find

develop
myk002 2021-08-24 21:06:12 -07:00
parent b2f44f00f1
commit 691e54dfc6
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 5 additions and 5 deletions

@ -47,7 +47,7 @@ function expect.ge(a, b, comment)
return a >= b, comment, ('%s < %s'):format(a, b)
end
function expect.find(pattern, str_to_match, comment)
function expect.str_find(pattern, str_to_match, comment)
if type(str_to_match) ~= 'string' then
return false, comment, 'expected string, got ' .. type(str_to_match)
end

@ -1,18 +1,18 @@
local expect_raw = require('test_util.expect')
function test.find()
expect.true_(expect_raw.find('a ', 'a str', 'a comment'))
expect.true_(expect_raw.str_find('a ', 'a str', 'a comment'))
local ok, comment, msg = expect_raw.find('ab', 'a str', 'a comment')
local ok, comment, msg = expect_raw.str_find('ab', 'a str', 'a comment')
expect.false_(ok)
expect.eq('a comment', comment)
expect.eq('pattern "ab" not matched in "a str"', msg)
ok, _, msg = expect_raw.find('pattern', nil)
ok, _, msg = expect_raw.str_find('pattern', nil)
expect.false_(ok)
expect.eq('expected string, got nil', msg)
ok, _, msg = expect_raw.find('pattern', {})
ok, _, msg = expect_raw.str_find('pattern', {})
expect.false_(ok)
expect.eq('expected string, got table', msg)
end