https://git.reactos.org/?p=reactos.git;a=commitdiff;h=07640a9a2110311d4e3e4…
commit 07640a9a2110311d4e3e429a0836995d6c5e73e5
Author: Bișoc George <fraizeraust99(a)gmail.com>
AuthorDate: Sun Apr 26 12:18:41 2020 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Apr 26 13:18:41 2020 +0300
[CRT_APITEST] Add testcase for mbtowc() (#2652)
---
.../rostests/apitests/crt/crtdll_crt_apitest.cmake | 2 +-
modules/rostests/apitests/crt/mbtowc.c | 61 ++++++++++++++++++++++
.../rostests/apitests/crt/msvcrt_crt_apitest.cmake | 2 +-
.../rostests/apitests/crt/ntdll_crt_apitest.cmake | 1 +
modules/rostests/apitests/crt/testlist.c | 2 +
5 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/modules/rostests/apitests/crt/crtdll_crt_apitest.cmake
b/modules/rostests/apitests/crt/crtdll_crt_apitest.cmake
index 8361b7b1105..768168681e8 100644
--- a/modules/rostests/apitests/crt/crtdll_crt_apitest.cmake
+++ b/modules/rostests/apitests/crt/crtdll_crt_apitest.cmake
@@ -425,7 +425,7 @@ list(APPEND SOURCE_CRTDLL
# malloc.c
# mblen.c
mbstowcs.c
-# mbtowc.c
+ mbtowc.c
# memchr.c
# memcmp.c
# memcpy.c
diff --git a/modules/rostests/apitests/crt/mbtowc.c
b/modules/rostests/apitests/crt/mbtowc.c
new file mode 100644
index 00000000000..50b014f66a0
--- /dev/null
+++ b/modules/rostests/apitests/crt/mbtowc.c
@@ -0,0 +1,61 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: Tests for mbtowc
+ * COPYRIGHT: Copyright 2020 Bișoc George <fraizeraust99 at gmail dot com>
+ */
+
+#include <apitest.h>
+#include <apitest_guard.h>
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+#include <stdlib.h>
+
+START_TEST(mbtowc)
+{
+ int Length;
+ wchar_t BufferDest[3];
+ char *ch;
+
+ ch = AllocateGuarded(sizeof(ch));
+ if (!ch)
+ {
+ skip("Buffer allocation failed!\n");
+ return;
+ }
+
+ /* Assign a character for tests */
+ *ch = 'A';
+
+ /* Everything is NULL */
+ Length = mbtowc(NULL, NULL, 0);
+ ok(Length == 0, "Expected 0 characters to be converted as everything is NULL but
got %u.\n", Length);
+
+ /* Don't examine the number of bytes pointed by multibyte parameter */
+ Length = mbtowc(BufferDest, ch, 0);
+ ok(Length == 0, "Expected 0 characters to be converted but got %u.\n",
Length);
+
+ /* Wide character argument is invalid */
+ Length = mbtowc(NULL, ch, 0);
+ ok(Length == 0, "Expected 0 characters to be converted but got %u.\n",
Length);
+
+ /* The multibyte argument is invalid */
+ Length = mbtowc(BufferDest, NULL, 0);
+ ok(Length == 0, "Expected 0 characters to be converted but got %u.\n",
Length);
+
+ /* The multibyte argument is invalid but count number for examination is correct */
+ Length = mbtowc(BufferDest, NULL, MB_CUR_MAX);
+ ok(Length == 0, "Expected 0 characters to be converted but got %u.\n",
Length);
+
+ /* Don't give the output but the count character inspection argument is valid */
+ Length = mbtowc(NULL, ch, MB_CUR_MAX);
+ ok(Length == 1, "The number of bytes to check should be 1 but got %u.\n",
Length);
+
+ /* Convert the character and validate the output that we should get */
+ Length = mbtowc(BufferDest, ch, MB_CUR_MAX);
+ ok(Length == 1, "Expected 1 character to be converted but got %u.\n",
Length);
+ ok_int(BufferDest[0], L'A');
+
+ FreeGuarded(ch);
+}
diff --git a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
index 619fcdfa780..2e3aaf9f3fc 100644
--- a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
+++ b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
@@ -1119,7 +1119,7 @@ list(APPEND SOURCE_MSVCRT
# mbsrtowcs_s
mbstowcs.c
# mbstowcs_s Not exported in 2k3 Sp1
-# mbtowc.c
+ mbtowc.c
# memchr.c
# memcmp.c
# memcpy.c
diff --git a/modules/rostests/apitests/crt/ntdll_crt_apitest.cmake
b/modules/rostests/apitests/crt/ntdll_crt_apitest.cmake
index b9ffc61c5f4..41322e1c338 100644
--- a/modules/rostests/apitests/crt/ntdll_crt_apitest.cmake
+++ b/modules/rostests/apitests/crt/ntdll_crt_apitest.cmake
@@ -72,6 +72,7 @@ list(APPEND SOURCE_NTDLL
# labs.c
# log.c
mbstowcs.c
+ mbtowc.c
# memchr.c
# memcmp.c
# memcpy == memmove
diff --git a/modules/rostests/apitests/crt/testlist.c
b/modules/rostests/apitests/crt/testlist.c
index 61516d82068..3afeb450484 100644
--- a/modules/rostests/apitests/crt/testlist.c
+++ b/modules/rostests/apitests/crt/testlist.c
@@ -17,6 +17,7 @@ extern void func__snwprintf(void);
extern void func__vsnprintf(void);
extern void func__vsnwprintf(void);
extern void func_mbstowcs(void);
+extern void func_mbtowc(void);
extern void func_sprintf(void);
extern void func_strcpy(void);
extern void func_strlen(void);
@@ -35,6 +36,7 @@ const struct test winetest_testlist[] =
{ "_vsnprintf", func__vsnprintf },
{ "_vsnwprintf", func__vsnwprintf },
{ "mbstowcs", func_mbstowcs },
+ { "mbtowc", func_mbtowc },
{ "_snprintf", func__snprintf },
{ "_snwprintf", func__snwprintf },
{ "sprintf", func_sprintf },