From a46c31f3569f22a8c161d220ac46c41d91470598 Mon Sep 17 00:00:00 2001 From: Learath Date: Wed, 13 Feb 2019 15:11:09 +0100 Subject: [PATCH] Add a couple tests, fix #1457 --- src/base/system.c | 4 ++-- src/test/str.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index cf9ad169e..58e6c4005 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -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; } diff --git a/src/test/str.cpp b/src/test/str.cpp index 56a623623..6be78b60e 100644 --- a/src/test/str.cpp +++ b/src/test/str.cpp @@ -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")); }