@@ -101,132 +101,4 @@ TEST(TestArithmeticOps, TestDiv) {
101101 context.Reset ();
102102}
103103
104- TEST (TestArithmeticOps, TestCastINT) {
105- gandiva::ExecutionContext ctx;
106-
107- int64_t ctx_ptr = reinterpret_cast <int64_t >(&ctx);
108-
109- EXPECT_EQ (castINT_utf8 (ctx_ptr, " -45" , 3 ), -45 );
110- EXPECT_EQ (castINT_utf8 (ctx_ptr, " 0" , 1 ), 0 );
111- EXPECT_EQ (castINT_utf8 (ctx_ptr, " 2147483647" , 10 ), 2147483647 );
112- EXPECT_EQ (castINT_utf8 (ctx_ptr, " 02147483647" , 11 ), 2147483647 );
113- EXPECT_EQ (castINT_utf8 (ctx_ptr, " -2147483648" , 11 ), -2147483648LL );
114- EXPECT_EQ (castINT_utf8 (ctx_ptr, " -02147483648" , 12 ), -2147483648LL );
115-
116- castINT_utf8 (ctx_ptr, " 2147483648" , 10 );
117- EXPECT_THAT (ctx.get_error (),
118- ::testing::HasSubstr (" Failed parsing the string to required format" ));
119- ctx.Reset ();
120-
121- castINT_utf8 (ctx_ptr, " -2147483649" , 11 );
122- EXPECT_THAT (ctx.get_error (),
123- ::testing::HasSubstr (" Failed parsing the string to required format" ));
124- ctx.Reset ();
125-
126- castINT_utf8 (ctx_ptr, " 12.34" , 5 );
127- EXPECT_THAT (ctx.get_error (),
128- ::testing::HasSubstr (" Failed parsing the string to required format" ));
129- ctx.Reset ();
130-
131- castINT_utf8 (ctx_ptr, " abc" , 3 );
132- EXPECT_THAT (ctx.get_error (),
133- ::testing::HasSubstr (" Failed parsing the string to required format" ));
134- ctx.Reset ();
135-
136- castINT_utf8 (ctx_ptr, " " , 0 );
137- EXPECT_THAT (ctx.get_error (),
138- ::testing::HasSubstr (" Failed parsing the string to required format" ));
139- ctx.Reset ();
140-
141- castINT_utf8 (ctx_ptr, " -" , 1 );
142- EXPECT_THAT (ctx.get_error (),
143- ::testing::HasSubstr (" Failed parsing the string to required format" ));
144- ctx.Reset ();
145- }
146-
147- TEST (TestArithmeticOps, TestCastBIGINT) {
148- gandiva::ExecutionContext ctx;
149-
150- int64_t ctx_ptr = reinterpret_cast <int64_t >(&ctx);
151-
152- EXPECT_EQ (castBIGINT_utf8 (ctx_ptr, " -45" , 3 ), -45 );
153- EXPECT_EQ (castBIGINT_utf8 (ctx_ptr, " 0" , 1 ), 0 );
154- EXPECT_EQ (castBIGINT_utf8 (ctx_ptr, " 9223372036854775807" , 19 ), 9223372036854775807LL );
155- EXPECT_EQ (castBIGINT_utf8 (ctx_ptr, " 09223372036854775807" , 20 ), 9223372036854775807LL );
156- EXPECT_EQ (castBIGINT_utf8 (ctx_ptr, " -9223372036854775808" , 20 ),
157- -9223372036854775807LL - 1 );
158- EXPECT_EQ (castBIGINT_utf8 (ctx_ptr, " -009223372036854775808" , 22 ),
159- -9223372036854775807LL - 1 );
160-
161- castBIGINT_utf8 (ctx_ptr, " 9223372036854775808" , 19 );
162- EXPECT_THAT (ctx.get_error (),
163- ::testing::HasSubstr (" Failed parsing the string to required format" ));
164- ctx.Reset ();
165-
166- castBIGINT_utf8 (ctx_ptr, " -9223372036854775809" , 20 );
167- EXPECT_THAT (ctx.get_error (),
168- ::testing::HasSubstr (" Failed parsing the string to required format" ));
169- ctx.Reset ();
170-
171- castBIGINT_utf8 (ctx_ptr, " 12.34" , 5 );
172- EXPECT_THAT (ctx.get_error (),
173- ::testing::HasSubstr (" Failed parsing the string to required format" ));
174- ctx.Reset ();
175-
176- castBIGINT_utf8 (ctx_ptr, " abc" , 3 );
177- EXPECT_THAT (ctx.get_error (),
178- ::testing::HasSubstr (" Failed parsing the string to required format" ));
179- ctx.Reset ();
180-
181- castBIGINT_utf8 (ctx_ptr, " " , 0 );
182- EXPECT_THAT (ctx.get_error (),
183- ::testing::HasSubstr (" Failed parsing the string to required format" ));
184- ctx.Reset ();
185-
186- castBIGINT_utf8 (ctx_ptr, " -" , 1 );
187- EXPECT_THAT (ctx.get_error (),
188- ::testing::HasSubstr (" Failed parsing the string to required format" ));
189- ctx.Reset ();
190- }
191-
192- TEST (TestArithmeticOps, TestCastFloat4) {
193- gandiva::ExecutionContext ctx;
194-
195- int64_t ctx_ptr = reinterpret_cast <int64_t >(&ctx);
196-
197- EXPECT_EQ (castFLOAT4_utf8 (ctx_ptr, " -45.34" , 6 ), -45 .34f );
198- EXPECT_EQ (castFLOAT4_utf8 (ctx_ptr, " 0" , 1 ), 0 .0f );
199- EXPECT_EQ (castFLOAT4_utf8 (ctx_ptr, " 5" , 1 ), 5 .0f );
200-
201- castFLOAT4_utf8 (ctx_ptr, " " , 0 );
202- EXPECT_THAT (ctx.get_error (),
203- ::testing::HasSubstr (" Failed parsing the string to required format" ));
204- ctx.Reset ();
205-
206- castFLOAT4_utf8 (ctx_ptr, " e" , 1 );
207- EXPECT_THAT (ctx.get_error (),
208- ::testing::HasSubstr (" Failed parsing the string to required format" ));
209- ctx.Reset ();
210- }
211-
212- TEST (TestParseStringHolder, TestCastFloat8) {
213- gandiva::ExecutionContext ctx;
214-
215- int64_t ctx_ptr = reinterpret_cast <int64_t >(&ctx);
216-
217- EXPECT_EQ (castFLOAT8_utf8 (ctx_ptr, " -45.34" , 6 ), -45.34 );
218- EXPECT_EQ (castFLOAT8_utf8 (ctx_ptr, " 0" , 1 ), 0.0 );
219- EXPECT_EQ (castFLOAT8_utf8 (ctx_ptr, " 5" , 1 ), 5.0 );
220-
221- castFLOAT8_utf8 (ctx_ptr, " " , 0 );
222- EXPECT_THAT (ctx.get_error (),
223- ::testing::HasSubstr (" Failed parsing the string to required format" ));
224- ctx.Reset ();
225-
226- castFLOAT8_utf8 (ctx_ptr, " e" , 1 );
227- EXPECT_THAT (ctx.get_error (),
228- ::testing::HasSubstr (" Failed parsing the string to required format" ));
229- ctx.Reset ();
230- }
231-
232104} // namespace gandiva
0 commit comments