Skip to content

Commit aa02da5

Browse files
committed
add test for float32; specify namespace of trunc
1 parent 7ac9090 commit aa02da5

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

cpp/src/gandiva/precompiled/arithmetic_ops.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ DIV(int64)
202202
gdv_fn_context_set_error_msg(context, err_msg); \
203203
return 0; \
204204
} \
205-
return static_cast<TYPE>(trunc(in1 / in2)); \
205+
return static_cast<TYPE>(::trunc(in1 / in2)); \
206206
}
207207

208208
DIV_FLOAT(float32)

cpp/src/gandiva/precompiled/arithmetic_ops_test.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,22 @@ TEST(TestArithmeticOps, TestDiv) {
7979
EXPECT_EQ(div_int64_int64(reinterpret_cast<int64>(&context), 101, 111), 0);
8080
EXPECT_EQ(context.has_error(), false);
8181
context.Reset();
82-
83-
EXPECT_EQ(div_float64_float64(reinterpret_cast<int64>(&context), 1010.1010, 2.1), 481.0);
82+
83+
EXPECT_EQ(div_float64_float64(reinterpret_cast<int64>(&context), 1010.1010, 2.1),
84+
481.0);
8485
EXPECT_EQ(context.has_error(), false);
8586
context.Reset();
86-
87-
EXPECT_EQ(div_float64_float64(reinterpret_cast<int64>(&context), 1010.1010, 0.00000), 0.0);
87+
88+
EXPECT_EQ(div_float64_float64(reinterpret_cast<int64>(&context), 1010.1010, 0.00000),
89+
0.0);
8890
EXPECT_EQ(context.has_error(), true);
8991
EXPECT_EQ(context.get_error(), "divide by zero error");
9092
context.Reset();
91-
93+
94+
EXPECT_EQ(div_float32_float32(reinterpret_cast<int64>(&context), 1010.1010f, 2.1f),
95+
481.0f);
96+
EXPECT_EQ(context.has_error(), false);
97+
context.Reset();
9298
}
9399

94100
} // namespace gandiva

cpp/src/gandiva/precompiled/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ float64 mod_float64_float64(int64 context, float64 left, float64 right);
126126
int64 divide_int64_int64(int64 context, int64 in1, int64 in2);
127127

128128
int64 div_int64_int64(int64 context, int64 in1, int64 in2);
129+
float32 div_float32_float32(int64 context, float32 in1, float32 in2);
129130
float64 div_float64_float64(int64 context, float64 in1, float64 in2);
130131

131132
float64 cbrt_int32(int32);

0 commit comments

Comments
 (0)