ReactOS  0.4.15-dev-3299-gbe8e5fc
mbtowc.c File Reference
#include <apitest.h>
#include <apitest_guard.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for mbtowc.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

 START_TEST (mbtowc)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file mbtowc.c.

Function Documentation

◆ START_TEST()

START_TEST ( mbtowc  )

Definition at line 15 of file mbtowc.c.

16 {
17  int Length;
18  wchar_t BufferDest[3];
19  char *ch;
20 
21  ch = AllocateGuarded(sizeof(ch));
22  if (!ch)
23  {
24  skip("Buffer allocation failed!\n");
25  return;
26  }
27 
28  /* Assign a character for tests */
29  *ch = 'A';
30 
31  /* Everything is NULL */
32  Length = mbtowc(NULL, NULL, 0);
33  ok(Length == 0, "Expected 0 characters to be converted as everything is NULL but got %u.\n", Length);
34 
35  /* Don't examine the number of bytes pointed by multibyte parameter */
36  Length = mbtowc(BufferDest, ch, 0);
37  ok(Length == 0, "Expected 0 characters to be converted but got %u.\n", Length);
38 
39  /* Wide character argument is invalid */
40  Length = mbtowc(NULL, ch, 0);
41  ok(Length == 0, "Expected 0 characters to be converted but got %u.\n", Length);
42 
43  /* The multibyte argument is invalid */
44  Length = mbtowc(BufferDest, NULL, 0);
45  ok(Length == 0, "Expected 0 characters to be converted but got %u.\n", Length);
46 
47  /* The multibyte argument is invalid but count number for examination is correct */
48  Length = mbtowc(BufferDest, NULL, MB_CUR_MAX);
49  ok(Length == 0, "Expected 0 characters to be converted but got %u.\n", Length);
50 
51  /* Don't give the output but the count character inspection argument is valid */
52  Length = mbtowc(NULL, ch, MB_CUR_MAX);
53  ok(Length == 1, "The number of bytes to check should be 1 but got %u.\n", Length);
54 
55  /* Convert the character and validate the output that we should get */
56  Length = mbtowc(BufferDest, ch, MB_CUR_MAX);
57  ok(Length == 1, "Expected 1 character to be converted but got %u.\n", Length);
58  ok_int(BufferDest[0], L'A');
59 
60  FreeGuarded(ch);
61 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static VOID FreeGuarded(_In_ PVOID Pointer)
Definition: apitest_guard.h:45
static PVOID AllocateGuarded(_In_ SIZE_T SizeRequested)
Definition: apitest_guard.h:10
#define ok_int(expression, result)
Definition: atltest.h:134
int CDECL mbtowc(wchar_t *dst, const char *str, size_t n)
Definition: mbtowc.c:53
static const WCHAR L[]
Definition: oid.c:1250
#define MB_CUR_MAX
Definition: ctype.h:624
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64