about summary refs log tree commit diff
path: root/string/tst-strlen.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/tst-strlen.c')
-rw-r--r--string/tst-strlen.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/string/tst-strlen.c b/string/tst-strlen.c
new file mode 100644
index 0000000000..a58f8784db
--- /dev/null
+++ b/string/tst-strlen.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <string.h>
+
+int
+main()
+{
+  static const lens[16] = { 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4 };
+  char buf[24];
+  int words;
+
+  for (words = 0; words < 4; ++words)
+    {
+      int last;
+      memset (buf, 'a', words * 4);
+
+      for (last = 0; last < 16; ++last)
+        {
+	  buf[words * 4 + 0] = (last & 1) != 0 ? 'b' : '\0';
+	  buf[words * 4 + 1] = (last & 2) != 0 ? 'c' : '\0';
+	  buf[words * 4 + 2] = (last & 4) != 0 ? 'd' : '\0';
+	  buf[words * 4 + 3] = (last & 8) != 0 ? 'e' : '\0';
+	  buf[words * 4 + 4] = '\0';
+
+	  if (strlen (buf) != words * 4 + lens[last])
+	    {
+	      printf ("failed for words=%d and last=%d\n", words, last);
+	      return 1;
+	    }
+        }
+    }
+  return 0;
+}