ReactOS 0.4.16-dev-112-g52265ae
_mbsncmp.c File Reference
#include <apitest.h>
#include <mbstring.h>
#include <pseh/pseh2.h>
#include <ndk/mmfuncs.h>
Include dependency graph for _mbsncmp.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define RETURN_DIFF   (g_WinVersion >= _WIN32_WINNT_VISTA)
 
#define DIFF_RETURN(sign, absolute)   (sign (RETURN_DIFF ? absolute : 1))
 

Functions

 START_TEST (_mbsncmp)
 

Variables

ULONG g_WinVersion
 

Macro Definition Documentation

◆ DIFF_RETURN

#define DIFF_RETURN (   sign,
  absolute 
)    (sign (RETURN_DIFF ? absolute : 1))

Definition at line 28 of file _mbsncmp.c.

◆ RETURN_DIFF

#define RETURN_DIFF   (g_WinVersion >= _WIN32_WINNT_VISTA)

Definition at line 25 of file _mbsncmp.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file _mbsncmp.c.

Function Documentation

◆ START_TEST()

START_TEST ( _mbsncmp  )

Definition at line 30 of file _mbsncmp.c.

31{
32 int ret;
33
35 g_WinVersion = (Version & 0xFF) << 8 | (Version & 0xFF00) >> 8;
36
37 /* Zero length always returns true */
38 ret = _mbsncmp(NULL, NULL, 0);
39 ok(ret == 0, "ret = %d\n", ret);
40
41 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"c", 0);
42 ok(ret == 0, "ret = %d\n", ret);
43
44 /* No null checks - length 1 crashes */
45 StartSeh()
46 (void)_mbsncmp((const unsigned char *)"a", NULL, 1);
48
49 StartSeh()
50 (void)_mbsncmp(NULL, (const unsigned char *)"c", 1);
52
53 /* Strings longer than or equal to length */
54 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"c", 1);
55 ok(ret == DIFF_RETURN(-, 2), "ret = %d\n", ret);
56
57 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"a", 1);
58 ok(ret == 0, "ret = %d\n", ret);
59
60 ret = _mbsncmp((const unsigned char *)"ab", (const unsigned char *)"aB", 1);
61 ok(ret == 0, "ret = %d\n", ret);
62
63 ret = _mbsncmp((const unsigned char *)"aa", (const unsigned char *)"ac", 2);
64 ok(ret == DIFF_RETURN(-, 2), "ret = %d\n", ret);
65
66 /* Length longer than one of the strings */
67 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"ac", 2);
68 ok(ret == DIFF_RETURN(-, 'c'), "ret = %d\n", ret);
69
70 ret = _mbsncmp((const unsigned char *)"aa", (const unsigned char *)"a", 2);
71 ok(ret == DIFF_RETURN(+, 'a'), "ret = %d\n", ret);
72
73 ret = _mbsncmp((const unsigned char *)"ab", (const unsigned char *)"ab", 100);
74 ok(ret == 0, "ret = %d\n", ret);
75}
#define DIFF_RETURN(sign, absolute)
Definition: _mbsncmp.c:28
ULONG g_WinVersion
Definition: _mbsncmp.c:14
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
_Check_return_ _CRTIMP int __cdecl _mbsncmp(_In_z_ const unsigned char *_Str1, _In_z_ const unsigned char *_Str2, _In_ size_t _MaxCount)
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
DWORD WINAPI GetVersion()
Definition: redirtest.c:5
uint32_t ULONG
Definition: typedefs.h:59
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

Variable Documentation

◆ g_WinVersion