Added some regression tests from patch #2321830
[fw/sdcc] / support / regression / tests / strstr.c
diff --git a/support/regression/tests/strstr.c b/support/regression/tests/strstr.c
new file mode 100644 (file)
index 0000000..da85f14
--- /dev/null
@@ -0,0 +1,18 @@
+/** tests for strstr
+*/
+#include <testfwk.h>
+#include <string.h>
+
+static void 
+teststrstr(void)
+{
+  char *a = "aabbcd";
+  ASSERT( strstr(a, "\0\1") == a);
+  ASSERT( strstr(a, "") == a);
+  ASSERT( strstr(a, "ab") == &a[1]);
+  ASSERT( strstr(a, "abc") == NULL);
+  ASSERT( strstr(a, "abbc") == &a[1]);
+  ASSERT( strstr("", "abbc") == NULL);
+/* ASSERT( strstr("", "") == a); should work, but it doesn't */
+  ASSERT( strstr(a, "cd") == &a[4]);
+}