ReactOS 0.4.16-dev-1946-g52006dd
_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 30 of file _mbsncmp.c.

◆ RETURN_DIFF

#define RETURN_DIFF   (g_WinVersion >= _WIN32_WINNT_VISTA)

Definition at line 27 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 32 of file _mbsncmp.c.

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

Variable Documentation

◆ g_WinVersion