Add a couple tests, fix #1457

This commit is contained in:
Learath 2019-02-13 15:11:09 +01:00
parent 37c67c00ad
commit a46c31f356
2 changed files with 6 additions and 2 deletions

View file

@ -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;
}

View file

@ -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"));
}