]> git.ipfire.org Git - thirdparty/glibc.git/blame - string/tst-strlen.c
update from main archive 961008
[thirdparty/glibc.git] / string / tst-strlen.c
CommitLineData
7a12c6bb
RM
1#include <stdio.h>
2#include <string.h>
3
4int
11336c16 5main(int argc, char *argv[])
7a12c6bb
RM
6{
7 static const lens[16] = { 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4 };
8 char buf[24];
9 int words;
10
11 for (words = 0; words < 4; ++words)
12 {
13 int last;
14 memset (buf, 'a', words * 4);
15
16 for (last = 0; last < 16; ++last)
17 {
18 buf[words * 4 + 0] = (last & 1) != 0 ? 'b' : '\0';
19 buf[words * 4 + 1] = (last & 2) != 0 ? 'c' : '\0';
20 buf[words * 4 + 2] = (last & 4) != 0 ? 'd' : '\0';
21 buf[words * 4 + 3] = (last & 8) != 0 ? 'e' : '\0';
22 buf[words * 4 + 4] = '\0';
23
24 if (strlen (buf) != words * 4 + lens[last])
25 {
26 printf ("failed for words=%d and last=%d\n", words, last);
27 return 1;
28 }
29 }
30 }
31 return 0;
32}