mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 23:18:39 +00:00
[CRT_APITEST] Add testcase for mbtowc() (#2652)
This commit is contained in:
parent
ab4b001e94
commit
07640a9a21
5 changed files with 66 additions and 2 deletions
|
@ -425,7 +425,7 @@ list(APPEND SOURCE_CRTDLL
|
||||||
# malloc.c
|
# malloc.c
|
||||||
# mblen.c
|
# mblen.c
|
||||||
mbstowcs.c
|
mbstowcs.c
|
||||||
# mbtowc.c
|
mbtowc.c
|
||||||
# memchr.c
|
# memchr.c
|
||||||
# memcmp.c
|
# memcmp.c
|
||||||
# memcpy.c
|
# memcpy.c
|
||||||
|
|
61
modules/rostests/apitests/crt/mbtowc.c
Normal file
61
modules/rostests/apitests/crt/mbtowc.c
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -1119,7 +1119,7 @@ list(APPEND SOURCE_MSVCRT
|
||||||
# mbsrtowcs_s
|
# mbsrtowcs_s
|
||||||
mbstowcs.c
|
mbstowcs.c
|
||||||
# mbstowcs_s Not exported in 2k3 Sp1
|
# mbstowcs_s Not exported in 2k3 Sp1
|
||||||
# mbtowc.c
|
mbtowc.c
|
||||||
# memchr.c
|
# memchr.c
|
||||||
# memcmp.c
|
# memcmp.c
|
||||||
# memcpy.c
|
# memcpy.c
|
||||||
|
|
|
@ -72,6 +72,7 @@ list(APPEND SOURCE_NTDLL
|
||||||
# labs.c
|
# labs.c
|
||||||
# log.c
|
# log.c
|
||||||
mbstowcs.c
|
mbstowcs.c
|
||||||
|
mbtowc.c
|
||||||
# memchr.c
|
# memchr.c
|
||||||
# memcmp.c
|
# memcmp.c
|
||||||
# memcpy == memmove
|
# memcpy == memmove
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern void func__snwprintf(void);
|
||||||
extern void func__vsnprintf(void);
|
extern void func__vsnprintf(void);
|
||||||
extern void func__vsnwprintf(void);
|
extern void func__vsnwprintf(void);
|
||||||
extern void func_mbstowcs(void);
|
extern void func_mbstowcs(void);
|
||||||
|
extern void func_mbtowc(void);
|
||||||
extern void func_sprintf(void);
|
extern void func_sprintf(void);
|
||||||
extern void func_strcpy(void);
|
extern void func_strcpy(void);
|
||||||
extern void func_strlen(void);
|
extern void func_strlen(void);
|
||||||
|
@ -35,6 +36,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "_vsnprintf", func__vsnprintf },
|
{ "_vsnprintf", func__vsnprintf },
|
||||||
{ "_vsnwprintf", func__vsnwprintf },
|
{ "_vsnwprintf", func__vsnwprintf },
|
||||||
{ "mbstowcs", func_mbstowcs },
|
{ "mbstowcs", func_mbstowcs },
|
||||||
|
{ "mbtowc", func_mbtowc },
|
||||||
{ "_snprintf", func__snprintf },
|
{ "_snprintf", func__snprintf },
|
||||||
{ "_snwprintf", func__snwprintf },
|
{ "_snwprintf", func__snwprintf },
|
||||||
{ "sprintf", func_sprintf },
|
{ "sprintf", func_sprintf },
|
||||||
|
|
Loading…
Reference in a new issue