ReactOS  0.4.14-dev-583-g2a1ba2c
RtlIntSafe.c File Reference
#include <kmt_test.h>
#include <ntintsafe.h>
Include dependency graph for RtlIntSafe.c:

Go to the source code of this file.

Macros

#define KMT_EMULATE_KERNEL
 
#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 10 of file RtlIntSafe.c.

◆ KMT_EMULATE_KERNEL

#define KMT_EMULATE_KERNEL

Definition at line 8 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)
_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:426
Status
Definition: gdiplustypes.h:24

◆ 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)
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
_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:426
Status
Definition: gdiplustypes.h:24
BOOLEAN Expected

Function Documentation

◆ START_TEST()

START_TEST ( RtlIntSafe  )

Definition at line 13 of file RtlIntSafe.c.

14 {
16  INT8 Int8Result;
17  UINT8 UInt8Result;
18  INT IntResult;
19  UINT UIntResult;
20  USHORT UShortResult;
21  SHORT ShortResult;
22  LONGLONG LongLongResult;
23 
24 #define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, Expected, ExpectedStatus) \
25  do \
26  { \
27  ToName ## Result = (ToType)0xfedcba9876543210; \
28  Status = Rtl ## FromName ## To ## ToName(Value, \
29  &ToName ## Result); \
30  ok_eq_hex(Status, ExpectedStatus); \
31  ok_eq_ ## Print(ToName ## Result, Expected); \
32  } while (0)
33 
34  TEST_CONVERSION(UInt8, UINT8, Int8, INT8, int, 0, 0, STATUS_SUCCESS);
35  TEST_CONVERSION(UInt8, UINT8, Int8, INT8, int, 5, 5, STATUS_SUCCESS);
39 
45 
51 
56 
62 
68 
76 
82 
83  TEST_CONVERSION(Int, INT, Int8, INT8, int, 0, 0, STATUS_SUCCESS);
84  TEST_CONVERSION(Int, INT, Int8, INT8, int, 5, 5, STATUS_SUCCESS);
91 
100 
101 #define TEST_ADD(_Name, _Type, _Print, _Value1, _Value2, _Expected, _Status) do \
102  { \
103  _Name ## Result = (_Type)0xfedcba9876543210; \
104  Status = Rtl ## _Name ## Add(_Value1, _Value2, & _Name ## Result); \
105  ok_eq_hex(Status, _Status); \
106  ok_eq_ ## _Print(_Name ## Result, _Expected); \
107  } while (0)
108 
109  TEST_ADD(UInt8, UINT8, uint, 0, 0, 0, STATUS_SUCCESS);
110  TEST_ADD(UInt8, UINT8, uint, 5, 5, 10, STATUS_SUCCESS);
116 
117  TEST_ADD(Int8, INT8, int, 0, 0, 0, STATUS_SUCCESS);
118  TEST_ADD(Int8, INT8, int, 5, 5, 10, STATUS_SUCCESS);
119  TEST_ADD(Int8, INT8, int, 0, INT8_MAX, INT8_MAX, STATUS_SUCCESS);
120  TEST_ADD(Int8, INT8, int, INT8_MAX, 0, INT8_MAX, STATUS_SUCCESS);
121  TEST_ADD(Int8, INT8, int, INT8_MAX - 1, 1, INT8_MAX, STATUS_SUCCESS);
122  TEST_ADD(Int8, INT8, int, INT8_MAX, 1, (INT8)-1, STATUS_INTEGER_OVERFLOW);
124  TEST_ADD(Int8, INT8, int, 0, -1, -1, STATUS_SUCCESS);
125  TEST_ADD(Int8, INT8, int, -1, 0, -1, STATUS_SUCCESS);
126  TEST_ADD(Int8, INT8, int, 0, INT8_MIN, INT8_MIN, STATUS_SUCCESS);
127  TEST_ADD(Int8, INT8, int, INT8_MIN, 0, INT8_MIN, STATUS_SUCCESS);
128  TEST_ADD(Int8, INT8, int, INT8_MAX, INT8_MIN, (INT8)-1, STATUS_SUCCESS);
129  TEST_ADD(Int8, INT8, int, INT8_MIN, -1, (INT8)-1, STATUS_INTEGER_OVERFLOW);
131 
132  TEST_ADD(LongLong, LONGLONG, longlong, 0, 0, 0, STATUS_SUCCESS);
133  TEST_ADD(LongLong, LONGLONG, longlong, 5, 5, 10, STATUS_SUCCESS);
134  TEST_ADD(LongLong, LONGLONG, longlong, 0, LONGLONG_MAX, LONGLONG_MAX, STATUS_SUCCESS);
135  TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MAX, 0, LONGLONG_MAX, STATUS_SUCCESS);
136  TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MAX - 1, 1, LONGLONG_MAX, STATUS_SUCCESS);
137  TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MAX, 1, (LONGLONG)-1, STATUS_INTEGER_OVERFLOW);
139  TEST_ADD(LongLong, LONGLONG, longlong, 0, -1, -1, STATUS_SUCCESS);
140  TEST_ADD(LongLong, LONGLONG, longlong, -1, 0, -1, STATUS_SUCCESS);
141  TEST_ADD(LongLong, LONGLONG, longlong, 0, LONGLONG_MIN, LONGLONG_MIN, STATUS_SUCCESS);
142  TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MIN, 0, LONGLONG_MIN, STATUS_SUCCESS);
143  TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MAX, LONGLONG_MIN, (LONGLONG)-1, STATUS_SUCCESS);
144  TEST_ADD(LongLong, LONGLONG, longlong, LONGLONG_MIN, -1, (LONGLONG)-1, STATUS_INTEGER_OVERFLOW);
146  TEST_ADD(LongLong, LONGLONG, longlong, ULONG_MAX, 1, 0x100000000LL, STATUS_SUCCESS);
147  TEST_ADD(LongLong, LONGLONG, longlong, ULONG_MAX, ULONG_MAX, 0x1fffffffeLL, STATUS_SUCCESS);
148 }
#define INT8_MAX
Definition: macro.lex.yy.c:69
#define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, Expected, ExpectedStatus)
signed char INT8
#define USHORT_MAX
Definition: intsafe.h:153
#define INT_MAX
Definition: limits.h:40
#define SHORT_MIN
Definition: intsafe.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define UInt8
Definition: interfaces.hpp:75
#define SHORT_MAX
Definition: intsafe.h:151
int32_t INT
Definition: typedefs.h:56
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:371
long LONG
Definition: pedump.c:60
unsigned short UShort
Definition: ftraster.c:312
short SHORT
Definition: pedump.c:59
#define UINT8_MAX
Definition: macro.lex.yy.c:78
unsigned long ULong
Definition: ftraster.c:314
short Short
Definition: ftraster.c:311
int64_t LONGLONG
Definition: typedefs.h:66
#define TEST_ADD(_Name, _Type, _Print, _Value1, _Value2, _Expected, _Status)
unsigned int UInt
Definition: ftraster.c:310
#define LONGLONG_MAX
Definition: intsafe.h:163
#define LONG_MAX
Definition: limits.h:43
#define INT8_MIN
Definition: macro.lex.yy.c:60
long Long
Definition: ftraster.c:313
Status
Definition: gdiplustypes.h:24
#define INT_MIN
Definition: limits.h:39
#define UINT_MAX
Definition: limits.h:41
unsigned short USHORT
Definition: pedump.c:61
#define LONGLONG_MIN
Definition: intsafe.h:132
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1
#define LONG_MIN
Definition: limits.h:42
UINT32 uint
Definition: types.h:83
return STATUS_SUCCESS
Definition: btrfs.c:2938
unsigned char UINT8
#define ULONG_MAX
Definition: limits.h:44
int Int
Definition: definitions.h:37