string: add a test case for a buggy situation of strtok

This commit is contained in:
Lephenixnoir 2021-08-17 17:28:37 +02:00
parent 684f827e99
commit c712416d12
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 2 additions and 1 deletions

View File

@ -92,10 +92,11 @@ static void _ft_string_naive(ft_test *t)
ft_assert(t, strstr(s1, "abcdabc") == NULL);
ft_assert(t, strcasestr(s1, "ABCdaBd") == s1 + 15);
char input[] = ",;,section 1;section 2,,section 3,,";
char input[] = ",;,section 1;section 2,,section 3,,section 4";
ft_assert(t, strcmp(strtok(input, ";,"), "section 1") == 0);
ft_assert(t, strcmp(strtok(NULL, ";,"), "section 2") == 0);
ft_assert(t, strcmp(strtok(NULL, ";,"), "section 3") == 0);
ft_assert(t, strcmp(strtok(NULL, ";,"), "section 4") == 0);
ft_assert(t, strtok(NULL, ";,") == NULL);
ft_assert(t, strtok(NULL, ";,") == NULL);
}