Author: tfaber
Date: Thu Nov 14 09:19:16 2013
New Revision: 60991

URL: http://svn.reactos.org/svn/reactos?rev=60991&view=rev
Log:
[KMTESTS:RTL]
- Add RtlIntSafe test for ntintsafe.h functions
CORE-7578

Added:
    trunk/rostests/kmtests/rtl/RtlIntSafe.c   (with props)
Modified:
    trunk/rostests/kmtests/CMakeLists.txt
    trunk/rostests/kmtests/kmtest/testlist.c
    trunk/rostests/kmtests/kmtest_drv/testlist.c

Modified: trunk/rostests/kmtests/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/CMakeLists.txt?rev=60991&r1=60990&r2=60991&view=diff
==============================================================================
--- trunk/rostests/kmtests/CMakeLists.txt       [iso-8859-1] (original)
+++ trunk/rostests/kmtests/CMakeLists.txt       [iso-8859-1] Thu Nov 14 
09:19:16 2013
@@ -12,6 +12,7 @@
     example/GuardedMemory.c
     rtl/RtlAvlTree.c
     rtl/RtlException.c
+    rtl/RtlIntSafe.c
     rtl/RtlMemory.c
     rtl/RtlRegistry.c
     rtl/RtlSplayTree.c

Modified: trunk/rostests/kmtests/kmtest/testlist.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest/testlist.c?rev=60991&r1=60990&r2=60991&view=diff
==============================================================================
--- trunk/rostests/kmtests/kmtest/testlist.c    [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest/testlist.c    [iso-8859-1] Thu Nov 14 
09:19:16 2013
@@ -12,6 +12,7 @@
 KMT_TESTFUNC Test_IoDeviceObject;
 KMT_TESTFUNC Test_RtlAvlTree;
 KMT_TESTFUNC Test_RtlException;
+KMT_TESTFUNC Test_RtlIntSafe;
 KMT_TESTFUNC Test_RtlMemory;
 KMT_TESTFUNC Test_RtlRegistry;
 KMT_TESTFUNC Test_RtlSplayTree;
@@ -25,6 +26,7 @@
     { "IoDeviceObject",     Test_IoDeviceObject },
     { "RtlAvlTree",         Test_RtlAvlTree },
     { "RtlException",       Test_RtlException },
+    { "RtlIntSafe",         Test_RtlIntSafe },
     { "RtlMemory",          Test_RtlMemory },
     { "RtlRegistry",        Test_RtlRegistry },
     { "RtlSplayTree",       Test_RtlSplayTree },

Modified: trunk/rostests/kmtests/kmtest_drv/testlist.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/testlist.c?rev=60991&r1=60990&r2=60991&view=diff
==============================================================================
--- trunk/rostests/kmtests/kmtest_drv/testlist.c        [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest_drv/testlist.c        [iso-8859-1] Thu Nov 14 
09:19:16 2013
@@ -47,6 +47,7 @@
 KMT_TESTFUNC Test_SeQueryInfoToken;
 KMT_TESTFUNC Test_RtlAvlTree;
 KMT_TESTFUNC Test_RtlException;
+KMT_TESTFUNC Test_RtlIntSafe;
 KMT_TESTFUNC Test_RtlMemory;
 KMT_TESTFUNC Test_RtlRegistry;
 KMT_TESTFUNC Test_RtlSplayTree;
@@ -97,6 +98,7 @@
     { "-SeQueryInfoToken",                  Test_SeQueryInfoToken },
     { "RtlAvlTreeKM",                       Test_RtlAvlTree },
     { "RtlExceptionKM",                     Test_RtlException },
+    { "RtlIntSafeKM",                       Test_RtlIntSafe },
     { "RtlMemoryKM",                        Test_RtlMemory },
     { "RtlRegistryKM",                      Test_RtlRegistry },
     { "RtlSplayTreeKM",                     Test_RtlSplayTree },

Added: trunk/rostests/kmtests/rtl/RtlIntSafe.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/rtl/RtlIntSafe.c?rev=60991
==============================================================================
--- trunk/rostests/kmtests/rtl/RtlIntSafe.c     (added)
+++ trunk/rostests/kmtests/rtl/RtlIntSafe.c     [iso-8859-1] Thu Nov 14 
09:19:16 2013
@@ -0,0 +1,98 @@
+/*
+ * PROJECT:         ReactOS kernel-mode tests
+ * LICENSE:         GPLv2+ - See COPYING in the top level directory
+ * PURPOSE:         Test for ntintsafe.h functions
+ * PROGRAMMER:      Thomas Faber <[email protected]>
+ */
+
+#define KMT_EMULATE_KERNEL
+#include <kmt_test.h>
+#include <ntintsafe.h>
+
+START_TEST(RtlIntSafe)
+{
+    NTSTATUS Status;
+    INT8 Int8Result;
+    UINT8 UInt8Result;
+    INT IntResult;
+    UINT UIntResult;
+    USHORT UShortResult;
+    SHORT ShortResult;
+
+#define TEST_CONVERSION(FromName, FromType, ToName, ToType, Print, Value, 
Expected, ExpectedStatus) \
+    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)
+
+    TEST_CONVERSION(UInt8, UINT8, Int8,   INT8,   int,  0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(UInt8, UINT8, Int8,   INT8,   int,  5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(UInt8, UINT8, Int8,   INT8,   int,  INT8_MAX,           
INT8_MAX,       STATUS_SUCCESS);
+    TEST_CONVERSION(UInt8, UINT8, Int8,   INT8,   int,  INT8_MAX + 1,       
(INT8)-1,       STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(UInt8, UINT8, Int8,   INT8,   int,  (UINT8)-1,          
(INT8)-1,       STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(ULong, ULONG, UShort, USHORT, uint, 0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, UShort, USHORT, uint, 5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, UShort, USHORT, uint, USHORT_MAX,         
USHORT_MAX,     STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, UShort, USHORT, uint, USHORT_MAX + 1,     
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(ULong, ULONG, UShort, USHORT, uint, (ULONG)-1,          
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(ULong, ULONG, Int,    INT,    int,  0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, Int,    INT,    int,  5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, Int,    INT,    int,  INT_MAX,            
INT_MAX,        STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, Int,    INT,    int,  (ULONG)INT_MAX + 1, 
(INT)-1,        STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(ULong, ULONG, Int,    INT,    int,  (ULONG)-1,          
(INT)-1,        STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(ULong, ULONG, UInt,   UINT,   uint, 0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, UInt,   UINT,   uint, 5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, UInt,   UINT,   uint, UINT_MAX,           
UINT_MAX,       STATUS_SUCCESS);
+    TEST_CONVERSION(ULong, ULONG, UInt,   UINT,   uint, (ULONG)-1,          
(UINT)-1,       STATUS_SUCCESS);
+
+    TEST_CONVERSION(Int8,  INT8,  UInt8,  UINT8,  uint, 0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int8,  INT8,  UInt8,  UINT8,  uint, 5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int8,  INT8,  UInt8,  UINT8,  uint, INT8_MAX,           
INT8_MAX,       STATUS_SUCCESS);
+    TEST_CONVERSION(Int8,  INT8,  UInt8,  UINT8,  uint, -1,                 
(UINT8)-1,      STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int8,  INT8,  UInt8,  UINT8,  uint, INT8_MIN,           
(UINT8)-1,      STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(Int8,  INT8,  UShort, USHORT, uint, 0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int8,  INT8,  UShort, USHORT, uint, 5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int8,  INT8,  UShort, USHORT, uint, INT8_MAX,           
INT8_MAX,       STATUS_SUCCESS);
+    TEST_CONVERSION(Int8,  INT8,  UShort, USHORT, uint, -1,                 
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int8,  INT8,  UShort, USHORT, uint, INT8_MIN,           
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, 0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, 5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, USHORT_MAX,         
USHORT_MAX,     STATUS_SUCCESS);
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, USHORT_MAX + 1,     
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, LONG_MAX,           
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, -1,                 
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Long,  LONG,  UShort, USHORT, uint, LONG_MIN,           
(USHORT)-1,     STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(Long,  LONG,  UInt,   UINT,   uint, 0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Long,  LONG,  UInt,   UINT,   uint, 5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Long,  LONG,  UInt,   UINT,   uint, LONG_MAX,           
LONG_MAX,       STATUS_SUCCESS);
+    TEST_CONVERSION(Long,  LONG,  UInt,   UINT,   uint, -1,                 
(UINT)-1,       STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Long,  LONG,  UInt,   UINT,   uint, LONG_MIN,           
(UINT)-1,       STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  INT8_MAX,           
INT8_MAX,       STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  INT8_MAX + 1,       
(INT8)-1,       STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  INT_MAX,            
(INT8)-1,       STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  INT8_MIN,           
INT8_MIN,       STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  INT8_MIN - 1,       
(INT8)-1,       STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int,   INT,   Int8,   INT8,   int,  INT_MIN,            
(INT8)-1,       STATUS_INTEGER_OVERFLOW);
+
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  0,                  0, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  5,                  5, 
             STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  SHORT_MAX,          
SHORT_MAX,      STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  SHORT_MAX + 1,      
(SHORT)-1,      STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  INT_MAX,            
(SHORT)-1,      STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  SHORT_MIN,          
SHORT_MIN,      STATUS_SUCCESS);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  SHORT_MIN - 1,      
(SHORT)-1,      STATUS_INTEGER_OVERFLOW);
+    TEST_CONVERSION(Int,   INT,   Short,  SHORT,  int,  INT_MIN,            
(SHORT)-1,      STATUS_INTEGER_OVERFLOW);
+}

Propchange: trunk/rostests/kmtests/rtl/RtlIntSafe.c
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to