[CRT_APITEST]
authorPierre Schweitzer <pierre@reactos.org>
Sat, 24 Oct 2015 23:18:33 +0000 (23:18 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 24 Oct 2015 23:18:33 +0000 (23:18 +0000)
Add a few tests to show mbstowcs/wcstombs behavior will NULL ptr.

CORE-10390

svn path=/trunk/; revision=69680

rostests/apitests/crt/crtdll_crt_apitest.cmake
rostests/apitests/crt/mbstowcs.c [new file with mode: 0644]
rostests/apitests/crt/msvcrt_crt_apitest.cmake
rostests/apitests/crt/ntdll_crt_apitest.cmake
rostests/apitests/crt/testlist.c
rostests/apitests/crt/wcstombs.c [new file with mode: 0644]

index 61f2af5..4556838 100644 (file)
@@ -425,7 +425,7 @@ list(APPEND SOURCE_CRTDLL
 #    longjmp.c
 #    malloc.c
 #    mblen.c
-#    mbstowcs.c
+    mbstowcs.c
 #    mbtowc.c
 #    memchr.c
 #    memcmp.c
@@ -517,7 +517,7 @@ list(APPEND SOURCE_CRTDLL
 #    wcstod.c
 #    wcstok.c
 #    wcstol.c
-#    wcstombs.c
+    wcstombs.c
 #    wcstoul.c
 #    wcsxfrm.c
 #    wctomb.c
diff --git a/rostests/apitests/crt/mbstowcs.c b/rostests/apitests/crt/mbstowcs.c
new file mode 100644 (file)
index 0000000..012fc7b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for mbstowcs
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+#include <stdlib.h>
+#include <specstrings.h>
+
+#define StrROS "ReactOS"
+
+
+START_TEST(mbstowcs)
+{
+    size_t len;
+
+    len = mbstowcs(NULL, StrROS, sizeof(StrROS) / sizeof(StrROS[0]));
+    ok(len == 7, "Got len = %u, excepting 7\n", len);
+    len = mbstowcs(NULL, StrROS, sizeof(StrROS) / sizeof(StrROS[0]) - 1);
+    ok(len == 7, "Got len = %u, excepting 7\n", len);
+}
index 6da1664..1f38759 100644 (file)
@@ -1117,7 +1117,7 @@ list(APPEND SOURCE_MSVCRT
 #    mbsdup_dbg
 #    mbsrtowcs
 #    mbsrtowcs_s
-#    mbstowcs.c
+    mbstowcs.c
 #    mbstowcs_s Not exported in 2k3 Sp1
 #    mbtowc.c
 #    memchr.c
@@ -1250,7 +1250,7 @@ list(APPEND SOURCE_MSVCRT
 #    wcstok.c
 #    wcstok_s.c
 #    wcstol.c
-#    wcstombs.c
+    wcstombs.c
 #    wcstombs_s.c Not exported in 2k3 Sp1
 #    wcstoul.c
 #    wcsxfrm.c
index a6432a3..93a27f9 100644 (file)
@@ -71,7 +71,7 @@ list(APPEND SOURCE_NTDLL
 #    isxdigit.c
 #    labs.c
 #    log.c
-#    mbstowcs.c
+    mbstowcs.c
 #    memchr.c
 #    memcmp.c
     # memcpy == memmove
@@ -120,7 +120,7 @@ list(APPEND SOURCE_NTDLL
 #    wcsstr.c
 #    wcstok.c
 #    wcstol.c
-#    wcstombs.c
+    wcstombs.c
 #    wcstoul.c
 )
 
index 13670f0..49eabd6 100644 (file)
@@ -12,15 +12,19 @@ extern void func__vscwprintf(void);
 #endif
 extern void func__vsnprintf(void);
 extern void func__vsnwprintf(void);
+extern void func_mbstowcs(void);
 extern void func_sprintf(void);
 extern void func_strcpy(void);
+extern void func_wcstombs(void);
 
 const struct test winetest_testlist[] =
 {
     { "_vsnprintf", func__vsnprintf },
     { "_vsnwprintf", func__vsnwprintf },
+    { "mbstowcs", func_mbstowcs },
     { "sprintf", func_sprintf },
     { "strcpy", func_strcpy },
+    { "wcstombs", func_wcstombs },
 #if defined(TEST_CRTDLL) || defined(TEST_MSVCRT) || defined(TEST_STATIC_CRT)
     // ...
 #endif
diff --git a/rostests/apitests/crt/wcstombs.c b/rostests/apitests/crt/wcstombs.c
new file mode 100644 (file)
index 0000000..1d21612
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for wcstombs
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+#include <stdlib.h>
+#include <specstrings.h>
+
+#define StrROS L"ReactOS"
+
+
+START_TEST(wcstombs)
+{
+    size_t len;
+
+    len = wcstombs(NULL, StrROS, sizeof(StrROS) / sizeof(StrROS[0]));
+    ok(len == 7, "Got len = %u, excepting 7\n", len);
+    len = wcstombs(NULL, StrROS, sizeof(StrROS) / sizeof(StrROS[0]) - 1);
+    ok(len == 7, "Got len = %u, excepting 7\n", len);
+}