1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
#ifndef TEST
char *
libsimple_strchrnul(const char *s_, int c_)
{
char *s = *(char **)(void *)&s_, c = (char)c_;
for (; *s && *s != c; s++);
return s;
}
#else
#include "test.h"
int
main(void)
{
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'c'), "cABCabcABCx"));
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'a'), "abcABCabcABCx"));
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'x'), "x"));
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'C'), "CabcABCx"));
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'A'), "ABCabcABCx"));
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", 'X'), ""));
assert(!strcmpnul(libsimple_strchrnul("abcABCabcABCx", '0'), ""));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'c'), "cABCabcX"));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'a'), "abcABCabcX"));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'x'), ""));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'C'), "CabcABCabcX"));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'A'), "ABCabcABCabcX"));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", 'X'), "X"));
assert(!strcmpnul(libsimple_strchrnul("ABCabcABCabcX", '0'), ""));
return 0;
}
#endif
|