ReactOS
0.4.16-dev-570-g1868985
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
m
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
_mbsstr.c
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS API tests
3
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4
* PURPOSE: Tests for _mbsstr
5
* COPYRIGHT: Copyright 2024 Thomas Faber (thomas.faber@reactos.org)
6
*/
7
8
#include <
apitest.h
>
9
#include <mbstring.h>
10
#define WIN32_NO_STATUS
11
#include <
pseh/pseh2.h
>
12
#include <
ndk/mmfuncs.h
>
13
14
START_TEST
(
_mbsstr
)
15
{
16
unsigned
char
*
haystack
;
17
unsigned
char
*
ret
;
18
19
/* NULL pointers are not handled */
20
StartSeh
()
21
(
void
)
_mbsstr
(
NULL
,
NULL
);
22
EndSeh
(
STATUS_ACCESS_VIOLATION
);
23
24
StartSeh
()
25
haystack
= (
unsigned
char
*)
"hello"
;
26
(
void
)
_mbsstr
(
haystack
,
NULL
);
27
EndSeh
(
STATUS_ACCESS_VIOLATION
);
28
29
StartSeh
()
30
haystack
= (
unsigned
char
*)
""
;
31
(
void
)
_mbsstr
(
haystack
,
NULL
);
32
EndSeh
(
STATUS_ACCESS_VIOLATION
);
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
}
87
StartSeh
#define StartSeh()
Definition:
_sntprintf.h:16
EndSeh
#define EndSeh(ExpectedStatus)
Definition:
_sntprintf.h:17
apitest.h
ok
#define ok(value,...)
Definition:
atltest.h:57
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
NULL
#define NULL
Definition:
types.h:112
_mbsstr
_Check_return_ _CRTIMP _CONST_RETURN unsigned char *__cdecl _mbsstr(_In_z_ const unsigned char *_Str, _In_z_ const unsigned char *_Substr)
void
Definition:
nsiface.idl:2307
haystack
static const char haystack[]
Definition:
editor.c:145
mmfuncs.h
STATUS_ACCESS_VIOLATION
#define STATUS_ACCESS_VIOLATION
Definition:
ntstatus.h:242
pseh2.h
ret
int ret
Definition:
wcstombs-tests.c:31
modules
rostests
apitests
crt
_mbsstr.c
Generated on Wed Jan 22 2025 06:07:04 for ReactOS by
1.9.6