1 /* Make sure we don't test the optimized inline functions if we want to
2 test the real implementation. */
3 #undef __USE_STRING_INLINES
9 main(int argc
, char *argv
[])
11 static const size_t lens
[] = { 0, 1, 0, 2, 0, 1, 0, 3,
12 0, 1, 0, 2, 0, 1, 0, 4 };
13 char basebuf
[24 + 32];
16 for (base
= 0; base
< 32; ++base
)
18 char *buf
= basebuf
+ base
;
21 for (words
= 0; words
< 4; ++words
)
24 memset (buf
, 'a', words
* 4);
26 for (last
= 0; last
< 16; ++last
)
28 buf
[words
* 4 + 0] = (last
& 1) != 0 ? 'b' : '\0';
29 buf
[words
* 4 + 1] = (last
& 2) != 0 ? 'c' : '\0';
30 buf
[words
* 4 + 2] = (last
& 4) != 0 ? 'd' : '\0';
31 buf
[words
* 4 + 3] = (last
& 8) != 0 ? 'e' : '\0';
32 buf
[words
* 4 + 4] = '\0';
34 if (strlen (buf
) != words
* 4 + lens
[last
])
37 strlen failed for base=%Zu, words=%Zu, and last=%Zu (is %zd, expected %zd)\n",
39 strlen (buf
), words
* 4 + lens
[last
]);
43 if (strnlen (buf
, -1) != words
* 4 + lens
[last
])
46 strnlen failed for base=%Zu, words=%Zu, and last=%Zu (is %zd, expected %zd)\n",
48 strnlen (buf
, -1), words
* 4 + lens
[last
]);