alsa.audio: add debug logs
[AROS.git] / test / clib / strtok.c
blobe68c32e11bfa224e05647a65589311e340a73fbc
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <string.h>
8 #include "test.h"
11 int main(void)
14 // strtok()
15 char str[] = "This;is,a test"; // must be array
16 char del[] = ",;";
17 char *ptr;
18 int cnt = 0;
20 ptr = strtok(str, del);
21 while (ptr)
23 cnt++;
24 switch(cnt)
26 case 1:
27 TEST( strcmp(ptr, "This") == 0 );
28 break;
29 case 2:
30 TEST( strcmp(ptr, "is") == 0 );
31 break;
32 case 3:
33 TEST( strcmp(ptr, "a test") == 0 );
34 break;
35 default:
36 TEST(0);
37 break;
39 printf("%s\n", ptr);
40 ptr = strtok(NULL, del);
45 // strtok_r()
46 char str[] = "This;is,a test"; // must be array
47 char del[] = ",;";
48 char *ptr, *save;
49 int cnt = 0;
51 ptr = strtok_r(str, del, &save);
52 while (ptr)
54 cnt++;
55 switch(cnt)
57 case 1:
58 TEST( strcmp(ptr, "This") == 0 );
59 break;
60 case 2:
61 TEST( strcmp(ptr, "is") == 0 );
62 break;
63 case 3:
64 TEST( strcmp(ptr, "a test") == 0 );
65 break;
66 default:
67 TEST(0);
68 break;
70 printf("%s\n", ptr);
71 ptr = strtok_r(NULL, del, &save);
74 return OK;
78 void cleanup()
80 /* Nothing to clean up */