diff options
author | Petr <30545094+pasabanov@users.noreply.github.com> | 2024-07-15 09:34:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 08:34:08 +0200 |
commit | e059daa0f16f73f27dbdb232ede037d1a43f1fee (patch) | |
tree | fd3a68af41ed75cccb92c3a424ce42dfd411efb2 /example | |
parent | f8e32bc75b3274daf3d9024449bbf0574436eda7 (diff) |
Optimize performance of ndpi_strnstr() and possible bugfix (#2494)
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpiReader.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index dd908e5ce..65246c05c 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -5782,6 +5782,13 @@ void strnstrUnitTest(void) { /* Test 13 */ assert(ndpi_strnstr("abcdef", "abc", 2) == NULL); + + /* Test 14: zero length */ + assert(strcmp(ndpi_strnstr("", "", 0), "") == 0); + assert(strcmp(ndpi_strnstr("string", "", 0), "string") == 0); + assert(ndpi_strnstr("", "str", 0) == NULL); + assert(ndpi_strnstr("string", "str", 0) == NULL); + assert(ndpi_strnstr("str", "string", 0) == NULL); } /* *********************************************** */ |