MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/arrow/util/ulp_distance_test.cc:98–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98TEST(TestWithinUlp, Double) {
99 for (double f : {0.0, 1e-20, 1.0, 2345678.9}) {
100 CheckWithinUlp(f, f, 0);
101 CheckWithinUlp(f, f, 1);
102 CheckWithinUlp(f, f, 42);
103 }
104 CheckWithinUlp(-0.0, 0.0, 1);
105 CheckWithinUlp(1.0, 1.0000000000000002, 1);
106 CheckWithinUlp(1.0, 1.0000000000000007, 3);
107 CheckNotWithinUlp(1.0, 1.0000000000000002, 0);
108 CheckNotWithinUlp(1.0, 1.0000000000000007, 2);
109 CheckNotWithinUlp(1.0, 1.0000000000000007, 1);
110 // left and right have a different exponent but are still very close
111 CheckWithinUlp(1.0, 0.9999999999999999, 1);
112 CheckWithinUlp(1.0, 0.9999999999999988, 11);
113 CheckNotWithinUlp(1.0, 0.9999999999999988, 10);
114 CheckWithinUlp(1.0000000000000002, 0.9999999999999999, 2);
115 CheckNotWithinUlp(1.0000000000000002, 0.9999999999999999, 1);
116 CheckWithinUlp(0.9999999999999988, 1.0000000000000007, 14);
117 CheckNotWithinUlp(0.9999999999999988, 1.0000000000000007, 13);
118
119 CheckWithinUlp(123.4567, 123.45670000000015, 11);
120 CheckNotWithinUlp(123.4567, 123.45670000000015, 10);
121
122 CheckWithinUlp(HUGE_VAL, HUGE_VAL, 10);
123 CheckWithinUlp(-HUGE_VAL, -HUGE_VAL, 10);
124 CheckWithinUlp(std::nan(""), std::nan(""), 10);
125 CheckNotWithinUlp(HUGE_VAL, -HUGE_VAL, 10);
126 CheckNotWithinUlp(12.34, -HUGE_VAL, 10);
127 CheckNotWithinUlp(12.34, std::nan(""), 10);
128 CheckNotWithinUlp(12.34, -12.34, 10);
129 CheckNotWithinUlp(0.0, 1e-20, 10);
130}
131
132TEST(TestWithinUlp, Float) {
133 for (float f : {0.0f, 1e-8f, 1.0f, 123.456f}) {

Callers

nothing calls this directly

Calls 4

CheckWithinUlpFunction · 0.85
CheckNotWithinUlpFunction · 0.85
ConvertToFloat16VectorFunction · 0.85
Float16Function · 0.70

Tested by

no test coverage detected