ReactOS 0.4.15-dev-7961-gdcf9eb0
_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   (GetVersion() >= 0x0600)
 
#define DIFF_RETURN(sign, absolute)   (sign (RETURN_DIFF ? absolute : 1))
 

Functions

 START_TEST (_mbsncmp)
 

Macro Definition Documentation

◆ DIFF_RETURN

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

Definition at line 26 of file _mbsncmp.c.

◆ RETURN_DIFF

#define RETURN_DIFF   (GetVersion() >= 0x0600)

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

29{
30 int ret;
31
32 /* Zero length always returns true */
33 ret = _mbsncmp(NULL, NULL, 0);
34 ok(ret == 0, "ret = %d\n", ret);
35
36 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"c", 0);
37 ok(ret == 0, "ret = %d\n", ret);
38
39 /* No null checks - length 1 crashes */
40 StartSeh()
41 (void)_mbsncmp((const unsigned char *)"a", NULL, 1);
43
44 StartSeh()
45 (void)_mbsncmp(NULL, (const unsigned char *)"c", 1);
47
48 /* Strings longer than or equal to length */
49 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"c", 1);
50 ok(ret == DIFF_RETURN(-, 2), "ret = %d\n", ret);
51
52 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"a", 1);
53 ok(ret == 0, "ret = %d\n", ret);
54
55 ret = _mbsncmp((const unsigned char *)"ab", (const unsigned char *)"aB", 1);
56 ok(ret == 0, "ret = %d\n", ret);
57
58 ret = _mbsncmp((const unsigned char *)"aa", (const unsigned char *)"ac", 2);
59 ok(ret == DIFF_RETURN(-, 2), "ret = %d\n", ret);
60
61 /* Length longer than one of the strings */
62 ret = _mbsncmp((const unsigned char *)"a", (const unsigned char *)"ac", 2);
63 ok(ret == DIFF_RETURN(-, 'c'), "ret = %d\n", ret);
64
65 ret = _mbsncmp((const unsigned char *)"aa", (const unsigned char *)"a", 2);
66 ok(ret == DIFF_RETURN(+, 'a'), "ret = %d\n", ret);
67
68 ret = _mbsncmp((const unsigned char *)"ab", (const unsigned char *)"ab", 100);
69 ok(ret == 0, "ret = %d\n", ret);
70}
#define DIFF_RETURN(sign, absolute)
Definition: _mbsncmp.c:26
#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
int ret