ReactOS 0.4.15-dev-8127-g6338913
RtlIntSafe.c File Reference
#include <rtltests.h>
#include <ntintsafe.h>
Include dependency graph for RtlIntSafe.c:

Go to the source code of this file.

Macros

#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
 
#define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, Expected, ExpectedStatus)
 
#define TEST_ADD(_Name, _Type, _Print, _Value1, _Value2, _Expected, _Status)
 

Functions

 START_TEST (RtlIntSafe)
 

Macro Definition Documentation

◆ ENABLE_INTSAFE_SIGNED_FUNCTIONS

#define ENABLE_INTSAFE_SIGNED_FUNCTIONS

Definition at line 9 of file RtlIntSafe.c.

◆ TEST_ADD

#define TEST_ADD (   _Name,
  _Type,
  _Print,
  _Value1,
  _Value2,
  _Expected,
  _Status 
)
Value:
do \
{ \
_Name ## Result = (_Type)0xfedcba9876543210; \
Status = Rtl ## _Name ## Add(_Value1, _Value2, & _Name ## Result); \
ok_eq_hex(Status, _Status); \
ok_eq_ ## _Print(_Name ## Result, _Expected); \
} while (0)
Status
Definition: gdiplustypes.h:25
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ TEST_CONVERSION

#define TEST_CONVERSION (   FromName,
  FromType,
  ToName,
  ToType,
  Print,
  Value,
  Expected,
  ExpectedStatus 
)
Value:
do \
{ \
ToName ## Result = (ToType)0xfedcba9876543210; \
Status = Rtl ## FromName ## To ## ToName(Value, \
&ToName ## Result); \
ok_eq_hex(Status, ExpectedStatus); \
ok_eq_ ## Print(ToName ## Result, Expected); \
} while (0)
BOOLEAN Expected
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Function Documentation

◆ START_TEST()

START_TEST ( RtlIntSafe  )

Definition at line 12 of file RtlIntSafe.c.

13{
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);
38
44
50
55
61
67
75
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);
90
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
109 TEST_ADD(UInt8, UINT8, uint, 5, 5, 10, STATUS_SUCCESS);
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);
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);
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);
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);
143 TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MIN, -1, (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}
signed char INT8
unsigned char UINT8
#define TEST_ADD(_Name, _Type, _Print, _Value1, _Value2, _Expected, _Status)
#define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, Expected, ExpectedStatus)
LONG NTSTATUS
Definition: precomp.h:26
int Int
Definition: definitions.h:37
UINT32 uint
Definition: types.h:83
#define UInt8
Definition: interfaces.hpp:75
unsigned short UShort
Definition: ftraster.c:312
long Long
Definition: ftraster.c:313
unsigned long ULong
Definition: ftraster.c:314
unsigned int UInt
Definition: ftraster.c:310
short Short
Definition: ftraster.c:311
#define INT_MIN
Definition: limits.h:39
#define ULONG_MAX
Definition: limits.h:44
#define LONG_MAX
Definition: limits.h:43
#define INT_MAX
Definition: limits.h:40
#define UINT_MAX
Definition: limits.h:41
#define LONG_MIN
Definition: limits.h:42
#define INT8_MIN
Definition: stdint.h:75
#define INT8_MAX
Definition: stdint.h:80
#define UINT8_MAX
Definition: stdint.h:85
#define SHORT_MIN
Definition: intsafe.h:121
#define USHORT_MAX
Definition: intsafe.h:147
#define LONGLONG_MIN
Definition: intsafe.h:126
#define SHORT_MAX
Definition: intsafe.h:145
#define LONGLONG_MAX
Definition: intsafe.h:157
unsigned int UINT
Definition: ndis.h:50
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
int64_t LONGLONG
Definition: typedefs.h:68
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59