ReactOS
0.4.16-dev-963-g182f353
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
RtlIntSafe.c
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS kernel-mode tests
3
* LICENSE: GPLv2+ - See COPYING in the top level directory
4
* PURPOSE: Test for ntintsafe.h functions
5
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6
*/
7
8
#include <
rtltests.h
>
9
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
10
#include <
ntintsafe.h
>
11
12
START_TEST
(RtlIntSafe)
13
{
14
NTSTATUS
Status
;
15
INT8
Int8Result;
16
UINT8
UInt8Result;
17
INT
IntResult;
18
UINT
UIntResult;
19
USHORT
UShortResult;
20
SHORT
ShortResult;
21
LONGLONG
LongLongResult;
22
23
#define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, Expected, ExpectedStatus) \
24
do \
25
{ \
26
ToName ## Result = (ToType)0xfedcba9876543210; \
27
Status = Rtl ## FromName ## To ## ToName(Value, \
28
&ToName ## Result); \
29
ok_eq_hex(Status, ExpectedStatus); \
30
ok_eq_ ## Print(ToName ## Result, Expected); \
31
} while (0)
32
33
TEST_CONVERSION
(
UInt8
,
UINT8
, Int8,
INT8
,
int
, 0, 0,
STATUS_SUCCESS
);
34
TEST_CONVERSION
(
UInt8
,
UINT8
, Int8,
INT8
,
int
, 5, 5,
STATUS_SUCCESS
);
35
TEST_CONVERSION
(
UInt8
,
UINT8
, Int8,
INT8
,
int
,
INT8_MAX
,
INT8_MAX
,
STATUS_SUCCESS
);
36
TEST_CONVERSION
(
UInt8
,
UINT8
, Int8,
INT8
,
int
,
INT8_MAX
+ 1, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
37
TEST_CONVERSION
(
UInt8
,
UINT8
, Int8,
INT8
,
int
, (
UINT8
)-1, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
38
39
TEST_CONVERSION
(
ULong
,
ULONG
,
UShort
,
USHORT
,
uint
, 0, 0,
STATUS_SUCCESS
);
40
TEST_CONVERSION
(
ULong
,
ULONG
,
UShort
,
USHORT
,
uint
, 5, 5,
STATUS_SUCCESS
);
41
TEST_CONVERSION
(
ULong
,
ULONG
,
UShort
,
USHORT
,
uint
,
USHORT_MAX
,
USHORT_MAX
,
STATUS_SUCCESS
);
42
TEST_CONVERSION
(
ULong
,
ULONG
,
UShort
,
USHORT
,
uint
,
USHORT_MAX
+ 1, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
43
TEST_CONVERSION
(
ULong
,
ULONG
,
UShort
,
USHORT
,
uint
, (
ULONG
)-1, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
44
45
TEST_CONVERSION
(
ULong
,
ULONG
,
Int
,
INT
,
int
, 0, 0,
STATUS_SUCCESS
);
46
TEST_CONVERSION
(
ULong
,
ULONG
,
Int
,
INT
,
int
, 5, 5,
STATUS_SUCCESS
);
47
TEST_CONVERSION
(
ULong
,
ULONG
,
Int
,
INT
,
int
,
INT_MAX
,
INT_MAX
,
STATUS_SUCCESS
);
48
TEST_CONVERSION
(
ULong
,
ULONG
,
Int
,
INT
,
int
, (
ULONG
)
INT_MAX
+ 1, (
INT
)-1,
STATUS_INTEGER_OVERFLOW
);
49
TEST_CONVERSION
(
ULong
,
ULONG
,
Int
,
INT
,
int
, (
ULONG
)-1, (
INT
)-1,
STATUS_INTEGER_OVERFLOW
);
50
51
TEST_CONVERSION
(
ULong
,
ULONG
,
UInt
,
UINT
,
uint
, 0, 0,
STATUS_SUCCESS
);
52
TEST_CONVERSION
(
ULong
,
ULONG
,
UInt
,
UINT
,
uint
, 5, 5,
STATUS_SUCCESS
);
53
TEST_CONVERSION
(
ULong
,
ULONG
,
UInt
,
UINT
,
uint
,
UINT_MAX
,
UINT_MAX
,
STATUS_SUCCESS
);
54
TEST_CONVERSION
(
ULong
,
ULONG
,
UInt
,
UINT
,
uint
, (
ULONG
)-1, (
UINT
)-1,
STATUS_SUCCESS
);
55
56
TEST_CONVERSION
(Int8,
INT8
,
UInt8
,
UINT8
,
uint
, 0, 0,
STATUS_SUCCESS
);
57
TEST_CONVERSION
(Int8,
INT8
,
UInt8
,
UINT8
,
uint
, 5, 5,
STATUS_SUCCESS
);
58
TEST_CONVERSION
(Int8,
INT8
,
UInt8
,
UINT8
,
uint
,
INT8_MAX
,
INT8_MAX
,
STATUS_SUCCESS
);
59
TEST_CONVERSION
(Int8,
INT8
,
UInt8
,
UINT8
,
uint
, -1, (
UINT8
)-1,
STATUS_INTEGER_OVERFLOW
);
60
TEST_CONVERSION
(Int8,
INT8
,
UInt8
,
UINT8
,
uint
,
INT8_MIN
, (
UINT8
)-1,
STATUS_INTEGER_OVERFLOW
);
61
62
TEST_CONVERSION
(Int8,
INT8
,
UShort
,
USHORT
,
uint
, 0, 0,
STATUS_SUCCESS
);
63
TEST_CONVERSION
(Int8,
INT8
,
UShort
,
USHORT
,
uint
, 5, 5,
STATUS_SUCCESS
);
64
TEST_CONVERSION
(Int8,
INT8
,
UShort
,
USHORT
,
uint
,
INT8_MAX
,
INT8_MAX
,
STATUS_SUCCESS
);
65
TEST_CONVERSION
(Int8,
INT8
,
UShort
,
USHORT
,
uint
, -1, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
66
TEST_CONVERSION
(Int8,
INT8
,
UShort
,
USHORT
,
uint
,
INT8_MIN
, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
67
68
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
, 0, 0,
STATUS_SUCCESS
);
69
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
, 5, 5,
STATUS_SUCCESS
);
70
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
,
USHORT_MAX
,
USHORT_MAX
,
STATUS_SUCCESS
);
71
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
,
USHORT_MAX
+ 1, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
72
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
,
LONG_MAX
, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
73
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
, -1, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
74
TEST_CONVERSION
(
Long
,
LONG
,
UShort
,
USHORT
,
uint
,
LONG_MIN
, (
USHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
75
76
TEST_CONVERSION
(
Long
,
LONG
,
UInt
,
UINT
,
uint
, 0, 0,
STATUS_SUCCESS
);
77
TEST_CONVERSION
(
Long
,
LONG
,
UInt
,
UINT
,
uint
, 5, 5,
STATUS_SUCCESS
);
78
TEST_CONVERSION
(
Long
,
LONG
,
UInt
,
UINT
,
uint
,
INT_MAX
,
INT_MAX
,
STATUS_SUCCESS
);
79
TEST_CONVERSION
(
Long
,
LONG
,
UInt
,
UINT
,
uint
, -1, (
UINT
)-1,
STATUS_INTEGER_OVERFLOW
);
80
TEST_CONVERSION
(
Long
,
LONG
,
UInt
,
UINT
,
uint
,
LONG_MIN
, (
UINT
)-1,
STATUS_INTEGER_OVERFLOW
);
81
82
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
, 0, 0,
STATUS_SUCCESS
);
83
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
, 5, 5,
STATUS_SUCCESS
);
84
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
,
INT8_MAX
,
INT8_MAX
,
STATUS_SUCCESS
);
85
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
,
INT8_MAX
+ 1, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
86
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
,
INT_MAX
, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
87
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
,
INT8_MIN
,
INT8_MIN
,
STATUS_SUCCESS
);
88
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
,
INT8_MIN
- 1, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
89
TEST_CONVERSION
(
Int
,
INT
, Int8,
INT8
,
int
,
INT_MIN
, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
90
91
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
, 0, 0,
STATUS_SUCCESS
);
92
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
, 5, 5,
STATUS_SUCCESS
);
93
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
,
SHORT_MAX
,
SHORT_MAX
,
STATUS_SUCCESS
);
94
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
,
SHORT_MAX
+ 1, (
SHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
95
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
,
INT_MAX
, (
SHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
96
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
,
SHORT_MIN
,
SHORT_MIN
,
STATUS_SUCCESS
);
97
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
,
SHORT_MIN
- 1, (
SHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
98
TEST_CONVERSION
(
Int
,
INT
,
Short
,
SHORT
,
int
,
INT_MIN
, (
SHORT
)-1,
STATUS_INTEGER_OVERFLOW
);
99
100
#define TEST_ADD(_Name, _Type, _Print, _Value1, _Value2, _Expected, _Status) do \
101
{ \
102
_Name ## Result = (_Type)0xfedcba9876543210; \
103
Status = Rtl ## _Name ## Add(_Value1, _Value2, & _Name ## Result); \
104
ok_eq_hex(Status, _Status); \
105
ok_eq_ ## _Print(_Name ## Result, _Expected); \
106
} while (0)
107
108
TEST_ADD
(
UInt8
,
UINT8
,
uint
, 0, 0, 0,
STATUS_SUCCESS
);
109
TEST_ADD
(
UInt8
,
UINT8
,
uint
, 5, 5, 10,
STATUS_SUCCESS
);
110
TEST_ADD
(
UInt8
,
UINT8
,
uint
, 0,
UINT8_MAX
,
UINT8_MAX
,
STATUS_SUCCESS
);
111
TEST_ADD
(
UInt8
,
UINT8
,
uint
,
UINT8_MAX
, 0,
UINT8_MAX
,
STATUS_SUCCESS
);
112
TEST_ADD
(
UInt8
,
UINT8
,
uint
,
UINT8_MAX
- 1, 1,
UINT8_MAX
,
STATUS_SUCCESS
);
113
TEST_ADD
(
UInt8
,
UINT8
,
uint
,
UINT8_MAX
, 1, (
UINT8
)-1,
STATUS_INTEGER_OVERFLOW
);
114
TEST_ADD
(
UInt8
,
UINT8
,
uint
,
UINT8_MAX
,
UINT8_MAX
, (
UINT8
)-1,
STATUS_INTEGER_OVERFLOW
);
115
116
TEST_ADD
(Int8,
INT8
,
int
, 0, 0, 0,
STATUS_SUCCESS
);
117
TEST_ADD
(Int8,
INT8
,
int
, 5, 5, 10,
STATUS_SUCCESS
);
118
TEST_ADD
(Int8,
INT8
,
int
, 0,
INT8_MAX
,
INT8_MAX
,
STATUS_SUCCESS
);
119
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MAX
, 0,
INT8_MAX
,
STATUS_SUCCESS
);
120
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MAX
- 1, 1,
INT8_MAX
,
STATUS_SUCCESS
);
121
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MAX
, 1, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
122
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MAX
,
INT8_MAX
, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
123
TEST_ADD
(Int8,
INT8
,
int
, 0, -1, -1,
STATUS_SUCCESS
);
124
TEST_ADD
(Int8,
INT8
,
int
, -1, 0, -1,
STATUS_SUCCESS
);
125
TEST_ADD
(Int8,
INT8
,
int
, 0,
INT8_MIN
,
INT8_MIN
,
STATUS_SUCCESS
);
126
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MIN
, 0,
INT8_MIN
,
STATUS_SUCCESS
);
127
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MAX
,
INT8_MIN
, (
INT8
)-1,
STATUS_SUCCESS
);
128
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MIN
, -1, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
129
TEST_ADD
(Int8,
INT8
,
int
,
INT8_MIN
,
INT8_MIN
, (
INT8
)-1,
STATUS_INTEGER_OVERFLOW
);
130
131
TEST_ADD
(LongLong,
LONGLONG
, longlong, 0, 0, (
LONGLONG
)0,
STATUS_SUCCESS
);
132
TEST_ADD
(LongLong,
LONGLONG
, longlong, 5, 5, (
LONGLONG
)10,
STATUS_SUCCESS
);
133
TEST_ADD
(LongLong,
LONGLONG
, longlong, 0,
LONGLONG_MAX
,
LONGLONG_MAX
,
STATUS_SUCCESS
);
134
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MAX
, 0,
LONGLONG_MAX
,
STATUS_SUCCESS
);
135
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MAX
- 1, 1,
LONGLONG_MAX
,
STATUS_SUCCESS
);
136
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MAX
, 1, (
LONGLONG
)-1,
STATUS_INTEGER_OVERFLOW
);
137
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MAX
,
INT8_MAX
, (
LONGLONG
)-1,
STATUS_INTEGER_OVERFLOW
);
138
TEST_ADD
(LongLong,
LONGLONG
, longlong, 0, -1, (
LONGLONG
)-1,
STATUS_SUCCESS
);
139
TEST_ADD
(LongLong,
LONGLONG
, longlong, -1, 0, (
LONGLONG
)-1,
STATUS_SUCCESS
);
140
TEST_ADD
(LongLong,
LONGLONG
, longlong, 0,
LONGLONG_MIN
,
LONGLONG_MIN
,
STATUS_SUCCESS
);
141
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MIN
, 0,
LONGLONG_MIN
,
STATUS_SUCCESS
);
142
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MAX
,
LONGLONG_MIN
, (
LONGLONG
)-1,
STATUS_SUCCESS
);
143
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MIN
, -1, (
LONGLONG
)-1,
STATUS_INTEGER_OVERFLOW
);
144
TEST_ADD
(LongLong,
LONGLONG
, longlong,
LONGLONG_MIN
,
LONGLONG_MIN
, (
LONGLONG
)-1,
STATUS_INTEGER_OVERFLOW
);
145
TEST_ADD
(LongLong,
LONGLONG
, longlong,
ULONG_MAX
, 1, 0x100000000LL,
STATUS_SUCCESS
);
146
TEST_ADD
(LongLong,
LONGLONG
, longlong,
ULONG_MAX
,
ULONG_MAX
, 0x1fffffffeLL,
STATUS_SUCCESS
);
147
}
INT8
signed char INT8
Definition:
ProcessorBind.h:197
UINT8
unsigned char UINT8
Definition:
ProcessorBind.h:189
TEST_ADD
#define TEST_ADD(_Name, _Type, _Print, _Value1, _Value2, _Expected, _Status)
TEST_CONVERSION
#define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, Expected, ExpectedStatus)
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
NTSTATUS
LONG NTSTATUS
Definition:
precomp.h:26
Int
int Int
Definition:
definitions.h:37
uint
UINT32 uint
Definition:
types.h:83
UInt8
#define UInt8
Definition:
interfaces.hpp:75
UShort
unsigned short UShort
Definition:
ftraster.c:311
Long
long Long
Definition:
ftraster.c:312
ULong
unsigned long ULong
Definition:
ftraster.c:313
UInt
unsigned int UInt
Definition:
ftraster.c:309
Short
short Short
Definition:
ftraster.c:310
Status
Status
Definition:
gdiplustypes.h:25
SHORT_MIN
#define SHORT_MIN
Definition:
intsafe.h:121
INT_MIN
#define INT_MIN
Definition:
intsafe.h:123
ULONG_MAX
#define ULONG_MAX
Definition:
intsafe.h:155
USHORT_MAX
#define USHORT_MAX
Definition:
intsafe.h:147
LONG_MAX
#define LONG_MAX
Definition:
intsafe.h:154
LONGLONG_MIN
#define LONGLONG_MIN
Definition:
intsafe.h:126
INT_MAX
#define INT_MAX
Definition:
intsafe.h:150
SHORT_MAX
#define SHORT_MAX
Definition:
intsafe.h:145
INT8_MIN
#define INT8_MIN
Definition:
intsafe.h:120
INT8_MAX
#define INT8_MAX
Definition:
intsafe.h:142
LONGLONG_MAX
#define LONGLONG_MAX
Definition:
intsafe.h:157
UINT_MAX
#define UINT_MAX
Definition:
intsafe.h:152
LONG_MIN
#define LONG_MIN
Definition:
intsafe.h:125
UINT8_MAX
#define UINT8_MAX
Definition:
intsafe.h:143
rtltests.h
UINT
unsigned int UINT
Definition:
ndis.h:50
ntintsafe.h
STATUS_INTEGER_OVERFLOW
#define STATUS_INTEGER_OVERFLOW
Definition:
ntstatus.h:385
SHORT
short SHORT
Definition:
pedump.c:59
LONG
long LONG
Definition:
pedump.c:60
USHORT
unsigned short USHORT
Definition:
pedump.c:61
STATUS_SUCCESS
#define STATUS_SUCCESS
Definition:
shellext.h:65
LONGLONG
int64_t LONGLONG
Definition:
typedefs.h:68
INT
int32_t INT
Definition:
typedefs.h:58
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
modules
rostests
apitests
rtl
RtlIntSafe.c
Generated on Mon Apr 7 2025 06:09:56 for ReactOS by
1.9.6