mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add a couple tests, fix #1457
This commit is contained in:
parent
37c67c00ad
commit
a46c31f356
|
@ -3054,11 +3054,11 @@ static const char *str_token_next(const char *str, const char *delim, int *lengt
|
|||
int str_in_list(const char *list, const char *delim, const char *needle)
|
||||
{
|
||||
const char *tok = list;
|
||||
int len = 0, notfound = 1;
|
||||
int len = 0, notfound = 1, needlelen = str_length(needle);
|
||||
|
||||
while(notfound && (tok = str_token_next(tok, delim, &len)))
|
||||
{
|
||||
notfound = str_comp_num(tok, needle, len);
|
||||
notfound = needlelen != len || str_comp_num(tok, needle, len);
|
||||
tok = tok + len;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,4 +147,8 @@ TEST(Str, InList)
|
|||
|
||||
EXPECT_FALSE(str_in_list(aTest, ",", "CHN"));
|
||||
EXPECT_FALSE(str_in_list(aTest, ",", "R,R"));
|
||||
|
||||
EXPECT_FALSE(str_in_list("abc,xyz", ",", "abcdef"));
|
||||
EXPECT_FALSE(str_in_list("", ",", ""));
|
||||
EXPECT_FALSE(str_in_list("", ",", "xyz"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue