This repository has been archived on 2021-04-17. You can view files and clone it, but cannot push or open issues or pull requests.
uIRC/tests/strtokmr.c

42 lines
1.0 KiB
C

#include "../src/misc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char* pointer = NULL;
if (strtok_mr(&pointer, "!") != NULL)
return EXIT_FAILURE;
if (pointer != NULL)
return EXIT_FAILURE;
char test2[] = "hello";
pointer = test2;
if (strtok_mr(&pointer, "!") == NULL)
return EXIT_FAILURE;
if (*pointer != '\0')
return EXIT_FAILURE;
char test3[] = "hi!# hello!";
pointer = test3;
if (strtok_mr(&pointer, "!#") == NULL)
return EXIT_FAILURE;
if (pointer != test3+3) /* MUST point at # right after ! */
return EXIT_FAILURE;
if (test3[2] != '\0') /* MUST replace ! with \0 */
return EXIT_FAILURE;
if (strtok_mr(&pointer, "!#") == NULL)
return EXIT_FAILURE;
if (pointer != test3+4) /* MUST point at whitespace right after # */
return EXIT_FAILURE;
if (test3[3] != '\0') /* MUST replace # with \0 */
return EXIT_FAILURE;
if (strtok_mr(&pointer, "!#") == NULL)
return EXIT_FAILURE;
if (strtok_mr(&pointer, "!#") != NULL)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}