Skip to content

Commit

Permalink
Add unit tests for struct Converter
Browse files Browse the repository at this point in the history
Add unit tests for struct Converter and Conversions.h.
struct Converter holds the core logic for casting between scalar
types. Source of the test cases are CastExprTest.cpp and
https://facebookincubator.github.io/velox/functions/presto/conversion.html
  • Loading branch information
gggrace14 committed Dec 6, 2023
1 parent 14dc44b commit e26180a
Show file tree
Hide file tree
Showing 3 changed files with 1,012 additions and 5 deletions.
7 changes: 3 additions & 4 deletions velox/expression/tests/CastExprTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,10 +1265,9 @@ TEST_F(CastExprTest, truncateVsRound) {
"tinyint", {1111111, 2, 3, 1000, -100101}, {71, 2, 3, -24, -5});

setCastIntByTruncate(false);
EXPECT_THROW(
(testCast<int32_t, int8_t>(
"tinyint", {1111111, 2, 3, 1000, -100101}, {71, 2, 3, -24, -5})),
VeloxUserError);
testCast<int32_t, int8_t>("tinyint", {2, 3}, {2, 3});
testCast<int32_t, int8_t>(
"tinyint", {1111111, 1000, -100101}, {0, 0, 0}, true);
}

TEST_F(CastExprTest, nullInputs) {
Expand Down
3 changes: 2 additions & 1 deletion velox/type/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ add_executable(
SubfieldTest.cpp
TimestampConversionTest.cpp
VariantTest.cpp
TimestampTest.cpp)
TimestampTest.cpp
ConversionsTest.cpp)

add_test(velox_type_test velox_type_test)

Expand Down
Loading

0 comments on commit e26180a

Please sign in to comment.