add wcsstr regression test
authorSzabolcs Nagy <nsz@port70.net>
Fri, 18 Apr 2014 22:15:07 +0000 (00:15 +0200)
committerSzabolcs Nagy <nsz@port70.net>
Fri, 18 Apr 2014 22:15:07 +0000 (00:15 +0200)
src/regression/memmem-oob.c
src/regression/rlimit-open-files.c
src/regression/wcsstr-false-negative.c [new file with mode: 0644]

index 2be928d..5249284 100644 (file)
@@ -1,3 +1,4 @@
+// commit 6fbdeff0e51f6afc38fbb1476a4db81322779da4 2014-04-09
 // memmem should not access oob data
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
index b946663..192ac35 100644 (file)
@@ -19,7 +19,7 @@ int main(void)
                t_error("setrlimit(%d, %ld) failed: %s\n", r, lim, strerror(errno));
        if (getrlimit(r, &rl))
                t_error("getrlimit(%d) failed: %s\n", r, strerror(errno));
-       if (lim != rl.rlim_max || lim != rl.rlim_cur)
+       if (rl.rlim_max != lim || rl.rlim_cur != lim)
                t_error("getrlimit %d says cur=%ld,max=%ld after setting the limit to %ld\n", r, rl.rlim_cur, rl.rlim_max, lim);
 
        while((fd=dup(1)) != -1)
diff --git a/src/regression/wcsstr-false-negative.c b/src/regression/wcsstr-false-negative.c
new file mode 100644 (file)
index 0000000..7283472
--- /dev/null
@@ -0,0 +1,14 @@
+// commit 476cd1d96560aaf7f210319597556e7fbcd60469 2014-04-18
+// wcsstr (strstr and memmem) failed to match repetitive needles in some cases
+#include <wchar.h>
+#include "test.h"
+
+int main(int argc, char* argv[])
+{
+       wchar_t const *haystack = L"playing play play play always";
+       wchar_t const *needle = L"play play play";
+       wchar_t *p = wcsstr(haystack, needle);
+       if (p != haystack+8)
+               t_error("wcsstr(L\"%S\",L\"%S\") failed: got %p, want %p\n", haystack, needle, p, haystack+8);
+       return t_status;
+}