ReactOS 0.4.15-dev-8236-g99f0937
__rt_div.c File Reference
#include <apitest.h>
Include dependency graph for __rt_div.c:

Go to the source code of this file.

Classes

struct  _SDIV_TEST_DATA
 
struct  _UDIV_TEST_DATA
 
struct  _SDIV64_TEST_DATA
 
struct  _UDIV64_TEST_DATA
 

Typedefs

typedef struct _SDIV_TEST_DATA SDIV_TEST_DATA
 
typedef struct _UDIV_TEST_DATA UDIV_TEST_DATA
 
typedef struct _SDIV64_TEST_DATA SDIV64_TEST_DATA
 
typedef struct _UDIV64_TEST_DATA UDIV64_TEST_DATA
 

Functions

 START_TEST (__rt_div)
 

Typedef Documentation

◆ SDIV64_TEST_DATA

◆ SDIV_TEST_DATA

◆ UDIV64_TEST_DATA

◆ UDIV_TEST_DATA

Function Documentation

◆ START_TEST()

START_TEST ( __rt_div  )

Definition at line 42 of file __rt_div.c.

43{
44 SDIV_TEST_DATA sdiv[] =
45 {
46 /* Dividend is larger than divisor */
47 { 3425, 400, 8, 225 },
48 { -3425, 400, -8, -225 },
49 { 3425, -400, -8, 225 },
50 { -3425, -400, 8, -225 },
51 /* Divisor is larger than dividend */
52 { 12, 42, 0, 12 },
53 { -12, 42, 0, -12 },
54 { 12, -42, 0, 12 },
55 { -12, -42, 0, -12 },
56 /* Division without remainder */
57 { 16777216, 65536, 256, 0 },
58 { -16777216, 65536, -256, 0 },
59 { 16777216, -65536, -256, 0 },
60 { -16777216, -65536, 256, 0 },
61 };
62 UDIV_TEST_DATA udiv[] =
63 {
64 /* Dividend is larger than divisor */
65 { 3425, 400, 8, 225 },
66 /* Divisor is larger than dividend */
67 { 12, 42, 0, 12 },
68 /* Division without remainder */
69 { 16777216, 65536, 256, 0 },
70 };
71 SDIV64_TEST_DATA sdiv64[] =
72 {
73 /* Dividend is larger than divisor */
74 { 34918215, 7, 4988316, 3 },
75 { -34918215, 7, -4988316, -3 },
76 { 34918215, -7, -4988316, 3 },
77 { -34918215, -7, 4988316, -3 },
78 /* Divisor is larger than dividend */
79 { 12, 42, 0, 12 },
80 { -12, 42, 0, -12 },
81 { 12, -42, 0, 12 },
82 { -12, -42, 0, -12 },
83 /* Division without remainder */
84 { 16777216, 65536, 256, 0 },
85 { -16777216, 65536, -256, 0 },
86 { 16777216, -65536, -256, 0 },
87 { -16777216, -65536, 256, 0 },
88
89 /* Big 64-bit numbers */
90
91 /* Dividend is larger than divisor */
92 { 0x2AFFFFFFFLL * 100, 400, 2885681151LL, 300 },
93 { -0x2AFFFFFFFLL * 100, 400, -2885681151LL, -300 },
94 { 0x2AFFFFFFFLL * 100, -400, -2885681151LL, 300 },
95 { -0x2AFFFFFFFLL * 100, -400, 2885681151LL, -300 },
96 /* Divisor is larger than dividend */
97 { 0x2AFFFFFFFLL * 50, 0x2AFFFFFFFLL * 100, 0, 0x2AFFFFFFFLL * 50 },
98 { -0x2AFFFFFFFLL * 50, 0x2AFFFFFFFLL * 100, 0, -0x2AFFFFFFFLL * 50 },
99 { 0x2AFFFFFFFLL * 50, -0x2AFFFFFFFLL * 100, 0, 0x2AFFFFFFFLL * 50 },
100 { -0x2AFFFFFFFLL * 50, -0x2AFFFFFFFLL * 100, 0, -0x2AFFFFFFFLL * 50 },
101 /* Division without remainder */
102 { 0x2AFFFFFFFLL * 100, 100, 0x2AFFFFFFFLL, 0 },
103 { -0x2AFFFFFFFLL * 100, 100, -0x2AFFFFFFFLL, 0 },
104 { 0x2AFFFFFFFLL * 100, -100, -0x2AFFFFFFFLL, 0 },
105 { -0x2AFFFFFFFLL * 100, -100, 0x2AFFFFFFFLL, 0 },
106 };
107 UDIV64_TEST_DATA udiv64[] =
108 {
109 /* Dividend is larger than divisor */
110 { 34918215, 7, 4988316, 3 },
111 /* Divisor is larger than dividend */
112 { 12, 42, 0, 12 },
113 /* Division without remainder */
114 { 16777216, 65536, 256, 0 },
115
116 /* Big 64-bit numbers */
117
118 /* Dividend is larger than divisor */
119 { 0x2AFFFFFFFULL * 100, 400, 2885681151ULL, 300 },
120 /* Divisor is larger than dividend */
121 { 0x2AFFFFFFFULL * 50, 0x2AFFFFFFFULL * 100, 0, 0x2AFFFFFFFULL * 50 },
122 /* Division without remainder */
123 { 0x2AFFFFFFFULL * 100, 100, 0x2AFFFFFFFULL, 0 },
124 };
125 INT i;
126
127 for (i = 0; i < _countof(sdiv); i++)
128 {
129 LONG test_div, test_mod;
130
131 test_div = sdiv[i].dividend / sdiv[i].divisor;
132 test_mod = sdiv[i].dividend % sdiv[i].divisor;
133 ok(test_div == sdiv[i].expected_div, "(sdiv) %d: Expected %ld, got %ld / %ld = %ld\n",
134 i, sdiv[i].expected_div, sdiv[i].dividend, sdiv[i].divisor, test_div);
135 ok(test_mod == sdiv[i].expected_mod, "(sdiv) %d: Expected %ld, got %ld %% %ld = %ld\n",
136 i, sdiv[i].expected_mod, sdiv[i].dividend, sdiv[i].divisor, test_mod);
137 }
138
139 for (i = 0; i < _countof(udiv); i++)
140 {
141 ULONG test_div, test_mod;
142
143 test_div = udiv[i].dividend / udiv[i].divisor;
144 test_mod = udiv[i].dividend % udiv[i].divisor;
145 ok(test_div == udiv[i].expected_div, "(udiv) %d: Expected %lu, got %lu / %lu = %lu\n",
146 i, udiv[i].expected_div, udiv[i].dividend, udiv[i].divisor, test_div);
147 ok(test_mod == udiv[i].expected_mod, "(udiv) %d: Expected %lu, got %lu %% %lu = %lu\n",
148 i, udiv[i].expected_mod, udiv[i].dividend, udiv[i].divisor, test_mod);
149 }
150
151 for (i = 0; i < _countof(sdiv64); i++)
152 {
153 LONGLONG test_div, test_mod;
154
155 test_div = sdiv64[i].dividend / sdiv64[i].divisor;
156 test_mod = sdiv64[i].dividend % sdiv64[i].divisor;
157 ok(test_div == sdiv64[i].expected_div, "(sdiv64) %d: Expected %lld, got %lld / %lld = %lld\n",
158 i, sdiv64[i].expected_div, sdiv64[i].dividend, sdiv64[i].divisor, test_div);
159 ok(test_mod == sdiv64[i].expected_mod, "(sdiv64) %d: Expected %lld, got %lld %% %lld = %lld\n",
160 i, sdiv64[i].expected_mod, sdiv64[i].dividend, sdiv64[i].divisor, test_mod);
161 }
162
163 for (i = 0; i < _countof(udiv64); i++)
164 {
165 ULONGLONG test_div, test_mod;
166
167 test_div = udiv64[i].dividend / udiv64[i].divisor;
168 test_mod = udiv64[i].dividend % udiv64[i].divisor;
169 ok(test_div == udiv64[i].expected_div, "(udiv64) %d: Expected %llu, got %llu / %llu = %llu\n",
170 i, udiv64[i].expected_div, udiv64[i].dividend, udiv64[i].divisor, test_div);
171 ok(test_mod == udiv64[i].expected_mod, "(udiv64) %d: Expected %llu, got %llu %% %llu = %llu\n",
172 i, udiv64[i].expected_mod, udiv64[i].dividend, udiv64[i].divisor, test_mod);
173 }
174}
#define ok(value,...)
Definition: atltest.h:57
GLuint divisor
Definition: glext.h:6313
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
#define _countof(array)
Definition: sndvol32.h:70
LONGLONG divisor
Definition: __rt_div.c:29
LONGLONG dividend
Definition: __rt_div.c:28
ULONGLONG divisor
Definition: __rt_div.c:37
ULONGLONG dividend
Definition: __rt_div.c:36
ULONG dividend
Definition: __rt_div.c:20
ULONG divisor
Definition: __rt_div.c:21
int64_t LONGLONG
Definition: typedefs.h:68
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67