• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef MATH_GTEST_MATH_DATA_TEST_H
2 #define MATH_GTEST_MATH_DATA_TEST_H
3 
4 #include <gtest/gtest.h>
5 #include <math.h>
6 #include <fenv.h>
7 
8 struct DataDoubleDouble {
9     double input;
10     double expected;
11 };
12 
13 struct DataFloatFloat {
14     float input;
15     float expected;
16 };
17 
18 struct DataIntFloat {
19     float input;
20     int expected;
21 };
22 
23 struct DataIntDouble {
24     double input;
25     int expected;
26 };
27 
28 struct DataLongDouble {
29     double input;
30     long expected;
31 };
32 
33 struct DataLongFloat {
34     float input;
35     long expected;
36 };
37 
38 struct DataLlongDouble {
39     double input;
40     long long expected;
41 };
42 
43 struct DataLlongFloat {
44     float input;
45     long long expected;
46 };
47 
48 struct DataDoubleDoubleInt {
49     double input1;
50     int input2;
51     double expected;
52 };
53 
54 struct DataFloatFloatInt {
55     float input1;
56     int input2;
57     float expected;
58 };
59 
60 struct DataDouble3Expected1 {
61     double input1;
62     double input2;
63     double expected;
64 };
65 
66 struct DataFloat3Expected1 {
67     float input1;
68     float input2;
69     float expected;
70 };
71 
72 struct DataDouble3Expected2 {
73     double input;
74     double expected1;
75     double expected2;
76 };
77 
78 struct DataFloat3Expected2 {
79     float input;
80     float expected1;
81     float expected2;
82 };
83 
84 struct DataFloatIntFloat {
85     float input;
86     float expected1;
87     int expected2;
88 };
89 
90 struct DataDoubleIntDouble {
91     double input;
92     double expected1;
93     int expected2;
94 };
95 
96 struct DataDouble3Int1 {
97     double input1;
98     double input2;
99     double expected1;
100     int expected2;
101 };
102 
103 struct DataFloat3Int1 {
104     float input1;
105     float input2;
106     float expected1;
107     int expected2;
108 };
109 
110 struct DataDouble4 {
111     double input1;
112     double input2;
113     double input3;
114     double expected;
115 };
116 
117 struct DataFloat4 {
118     float input1;
119     float input2;
120     float input3;
121     float expected;
122 };
123 
124 union FloatShape {
125     float value;
126     struct {
127         unsigned frac : 23;
128         unsigned exp : 8;
129         unsigned sign : 1;
130     } bits;
131     uint32_t sign_magnitude;
132 };
133 
134 union DoubleShape {
135     double value;
136     struct {
137         unsigned fracl;
138         unsigned frach : 20;
139         unsigned exp : 11;
140         unsigned sign : 1;
141     } bits;
142     uint64_t sign_magnitude;
143 };
144 
145 uint64_t ConvertDoubleToBiased(const double &value);
146 bool DoubleUlpCmp(double expected, double actual, uint64_t ulp);
147 uint32_t ConvertFloatToBiased(const float &value);
148 bool FloatUlpCmp(float expected, float actual, uint32_t ulp);
149 
150 #endif