mirror of
https://github.com/cc65/cc65.git
synced 2024-12-26 08:32:00 +00:00
Test strtok().
This commit is contained in:
parent
0541b65aa4
commit
cdb2d49e3a
43
test/ref/strtok.c
Normal file
43
test/ref/strtok.c
Normal file
@ -0,0 +1,43 @@
|
||||
// 2024-02-14 Sven Michael Klose <pixel@hugbox.org>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
error (void)
|
||||
{
|
||||
printf ("strtok() test failed!\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
void
|
||||
test (char * s)
|
||||
{
|
||||
if (strcmp ("test", strtok (s, "/")))
|
||||
error ();
|
||||
if (strcmp ("foo", strtok (NULL, "/")))
|
||||
error ();
|
||||
if (strcmp ("bar", strtok (NULL, "/")))
|
||||
error ();
|
||||
if (strtok (NULL, "/"))
|
||||
error ();
|
||||
if (strtok (NULL, "/"))
|
||||
error ();
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char s1[] = "test/foo/bar";
|
||||
char s2[] = "/test/foo/bar";
|
||||
char s3[] = "//test/foo/bar";
|
||||
char s4[] = "//test/foo/bar//";
|
||||
|
||||
test (s1);
|
||||
test (s2);
|
||||
test (s3);
|
||||
test (s4);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user