ReactOS 0.4.15-dev-7961-gdcf9eb0
_mbsstr.c File Reference
#include <apitest.h>
#include <mbstring.h>
#include <pseh/pseh2.h>
#include <ndk/mmfuncs.h>
Include dependency graph for _mbsstr.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

 START_TEST (_mbsstr)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file _mbsstr.c.

Function Documentation

◆ START_TEST()

START_TEST ( _mbsstr  )

Definition at line 14 of file _mbsstr.c.

15{
16 unsigned char *haystack;
17 unsigned char *ret;
18
19 /* NULL pointers are not handled */
20 StartSeh()
23
24 StartSeh()
25 haystack = (unsigned char *)"hello";
26 (void)_mbsstr(haystack, NULL);
28
29 StartSeh()
30 haystack = (unsigned char *)"";
31 (void)_mbsstr(haystack, NULL);
33
34 /* Empty needle returns haystack, empty haystack returns NULL... */
35 haystack = (unsigned char *)"hello";
36 ret = _mbsstr(haystack, (const unsigned char *)"");
37 ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);
38
39 haystack = (unsigned char *)"";
40 ret = _mbsstr(haystack, (const unsigned char *)"a");
41 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
42
43 /* ... but if both are empty, behavior differs */
44 haystack = (unsigned char *)"";
45 ret = _mbsstr(haystack, (const unsigned char *)"");
46#ifdef TEST_CRTDLL
47 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
48#else
49 ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);
50#endif
51
52 /* Simple "found" cases */
53 haystack = (unsigned char *)"abcdefg";
54 ret = _mbsstr(haystack, (const unsigned char *)"abc");
55 ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);
56
57 haystack = (unsigned char *)"abcdefg";
58 ret = _mbsstr(haystack, (const unsigned char *)"g");
59 ok(ret == haystack + 6, "ret = %p, haystack = %p\n", ret, haystack);
60
61 haystack = (unsigned char *)"abcdefg";
62 ret = _mbsstr(haystack, (const unsigned char *)"abcdefg");
63 ok(ret == haystack, "ret = %p, haystack = %p\n", ret, haystack);
64
65 /* Simple "not found" cases */
66 haystack = (unsigned char *)"abcdefg";
67 ret = _mbsstr(haystack, (const unsigned char *)"h");
68 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
69
70 haystack = (unsigned char *)"abcdefg";
71 ret = _mbsstr(haystack, (const unsigned char *)"gh");
72 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
73
74 haystack = (unsigned char *)"abcdefg";
75 ret = _mbsstr(haystack, (const unsigned char *)"abcD");
76 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
77
78 /* Needle longer than haystack */
79 haystack = (unsigned char *)"abcdefg";
80 ret = _mbsstr(haystack, (const unsigned char *)"abcdefgh");
81 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
82
83 haystack = (unsigned char *)"abcdefg";
84 ret = _mbsstr(haystack, (const unsigned char *)"xxxxxxxx");
85 ok(ret == NULL, "ret = %p, haystack = %p\n", ret, haystack);
86}
#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
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP _CONST_RETURN unsigned char *__cdecl _mbsstr(_In_z_ const unsigned char *_Str, _In_z_ const unsigned char *_Substr)
Definition: ctx.idl:7
static const char haystack[]
Definition: editor.c:145
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
int ret
#define const
Definition: zconf.h:233