54 ok (
strlen (
"Hello world!" ) == 12 );
55 ok (
strlen (
"Hello\0world!" ) == 5 );
64 ok (
strnlen (
"Hello world!", 5 ) == 5 );
65 ok (
strnlen (
"Hello world!", 11 ) == 11 );
66 ok (
strnlen (
"Hello world!", 16 ) == 12 );
70 ok ( *(
strchr (
"Testing",
'e' )) ==
'e' );
71 ok ( *(
strchr (
"Testing",
'g' )) ==
'g' );
73 ok ( *(
strchr (
"Testing",
'\0' )) ==
'\0' );
77 ok ( *(
strrchr (
"Haystack",
'a' )) ==
'a' );
78 ok ( *(
strrchr (
"Haystack",
'k' )) ==
'k' );
86 ok ( *(
strchrnul (
"Nonstandard",
'\0' )) ==
'\0' );
96 ok (
strcmp (
"Hello",
"Hello" ) == 0 );
97 ok (
strcmp (
"Hello",
"hello" ) != 0 );
98 ok (
strcmp (
"Hello",
"Hello world!" ) != 0 );
99 ok (
strcmp (
"Hello world!",
"Hello" ) != 0 );
105 ok (
strncmp (
"Goodbye",
"Goodbye", 16 ) == 0 );
106 ok (
strncmp (
"Goodbye",
"Hello", 16 ) != 0 );
107 ok (
strncmp (
"Goodbye",
"Goodbye world", 32 ) != 0 );
108 ok (
strncmp (
"Goodbye",
"Goodbye world", 7 ) == 0 );
127 ok (
memcmp (
"Foo",
"Foo", 3 ) == 0 );
128 ok (
memcmp (
"Foo",
"Bar", 3 ) != 0 );
129 ok (
memcmp (
"abc",
"def", 3 ) < 0 );
133 const char haystack[] =
"find me!";
136 found =
strstr ( haystack,
"find" );
137 ok ( found == &haystack[0] );
138 found =
strstr ( haystack,
"me" );
139 ok ( found == &haystack[5] );
140 found =
strstr ( haystack,
"me." );
146 const char haystack[] =
"Find ME!";
150 ok ( found == &haystack[0] );
152 ok ( found == &haystack[5] );
159 static uint8_t test[7] = {
'>', 1, 1, 1, 1, 1,
'<' };
160 static const uint8_t expected[7] = {
'>', 0, 0, 0, 0, 0,
'<' };
166 static const uint8_t expected[4] = {
'>', 0xeb, 0xeb,
'<' };
174 {
'>', 1, 2, 3, 4, 5, 6, 7, 8, 9,
'<' };
175 static const uint8_t expected[11] =
176 {
'>', 3, 4, 5, 6, 7, 8, 7, 8, 9,
'<' };
182 {
'>', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
'<' };
183 static const uint8_t expected[12] =
184 {
'>', 1, 2, 3, 4, 5, 1, 2, 3, 4, 5,
'<' };
192 {
'>', 1, 2, 3, 7, 8, 9,
'<' };
193 static const uint8_t expected[8] =
194 {
'>', 7, 8, 9, 1, 2, 3,
'<' };
201 const char *orig =
"testing testing";
202 char *dup =
strdup ( orig );
211 const char *
normal =
"testing testing";
212 const char unterminated[6] = {
'h',
'e',
'l',
'l',
'o',
'!' };
223 dup =
strndup ( unterminated, 5 );
225 ok (
strcmp ( dup,
"hello" ) == 0 );
231 const char longer[12] =
"duplicateme";
232 const char shorter[6] =
"hello";
237 ok ( *dnul ==
'\0' );
241 ok ( *dnul ==
'\0' );
249 const char longer[7] =
"copyme";
250 const char shorter[3] =
"hi";
265 const char src[5] =
"copy";
266 const char orig[8] = {
'x',
'x',
'x',
'x',
'x',
'x',
'x',
'x' };
267 const char zero[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
294 char buf[16] =
"append";
299 ok (
strcmp ( buf,
"append this" ) == 0 );
306 for ( i = 0 ; i < 16 ; i++ ) {
307 snprintf ( buf,
sizeof ( buf ),
"%x", i );
309 snprintf ( buf,
sizeof ( buf ),
"%X", i );
336 static const char string[] =
"123aHa.world";
338 ok (
strtoul (
string, &endp, 0 ) == 123UL );
339 ok ( endp == &
string[3] );
340 ok (
strtoul (
string, &endp, 16 ) == 0x123aUL );
341 ok ( endp == &
string[4] );
343 ( ( ( ( ( 1 * 26 + 2 ) * 26 + 3 ) * 26 + 10 ) * 26
344 + 17 ) * 26 + 10 ) );
345 ok ( endp == &
string[6] );
351 ok (
wcslen ( L
"Helloo woorld!" ) == 14 );
352 ok (
wcslen ( L
"Helloo\0woorld!" ) == 6 );
361 ok (
wcsnlen ( L
"Helloo woorld!", 5 ) == 5 );
362 ok (
wcsnlen ( L
"Helloo woorld!", 11 ) == 11 );
363 ok (
wcsnlen ( L
"Helloo woorld!", 16 ) == 14 );
#define NULL
NULL pointer (VOID *).
struct arbelprm_completion_queue_entry normal
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void * memmove(void *dest, const void *src, size_t len) __nonnull
static void(* free)(struct refcnt *refcnt))
char * strcat(char *dest, const char *src)
Concatenate string.
void * memswap(void *first, void *second, size_t len)
Swap memory regions.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
int strcmp(const char *first, const char *second)
Compare strings.
char * strchr(const char *src, int character)
Find character within a string.
int strncasecmp(const char *first, const char *second, size_t max)
Compare case-insensitive strings.
char * strdup(const char *src)
Duplicate string.
void * memchr(const void *src, int character, size_t len)
Find character within a memory region.
char * stpcpy(char *dest, const char *src)
Copy string.
int strncmp(const char *first, const char *second, size_t max)
Compare strings.
size_t strnlen(const char *src, size_t max)
Get length of string.
unsigned int digit_value(unsigned int character)
Calculate digit value.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
char * strndup(const char *src, size_t max)
Duplicate string.
char * strstr(const char *haystack, const char *needle)
Find substring.
char * strrchr(const char *src, int character)
Find rightmost character within a string.
char * strcpy(char *dest, const char *src)
Copy string.
char * strcasestr(const char *haystack, const char *needle)
Find case-insensitive substring.
size_t strlen(const char *src)
Get length of string.
char * strchrnul(const char *src, int character)
Find character within a string, or NUL terminator.
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
static void string_test_exec(void)
Perform string self-tests.
Self-test infrastructure.
#define __self_test
Declare a self-test.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
size_t wcsnlen(const wchar_t *string, size_t max)
Calculate length of wide-character string.
size_t wcslen(const wchar_t *string)
Calculate length of wide-character string.