Skip to content

Commit

Permalink
Cleanup test to use evaluateOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanCutler committed Sep 23, 2024
1 parent c8e2907 commit 918598f
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion velox/functions/prestosql/tests/UuidFunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,53 @@ TEST_F(UuidFunctionsTest, unsupportedCast) {
}

TEST_F(UuidFunctionsTest, comparisons) {
const auto uuidEval = [&](const std::optional<std::string>& lhs, const std::string& operation, const std::optional<std::string>& rhs) {
return evaluateOnce<bool>(fmt::format("cast(c0 as uuid) {} cast(c1 as uuid)", operation), lhs, rhs);
};
/*const auto uuidComparison = [&](const std::string& operation, const std::optional<std::string>& lhs, const std::optional<std::string>& rhs) {
return evaluateOnce<bool>(fmt::format("cast(c0 as uuid) {} cast(c1 as uuid)", operation), lhs, rhs);
};
const auto uuidLt = std::bind(uuidComparison, ">", std::placeholders::_1, std::placeholders::_2);
const auto uuidGt = std::bind(uuidComparison, ">", std::placeholders::_1, std::placeholders::_2);
const auto uuidLtEq = std::bind(uuidComparison, "<=", std::placeholders::_1, std::placeholders::_2);
const auto uuidGtEq = std::bind(uuidComparison, ">", std::placeholders::_1, std::placeholders::_2);
const auto uuidEq = std::bind(uuidComparison, "==", std::placeholders::_1, std::placeholders::_2);
const auto uuidNotEq = std::bind(uuidComparison, "!=", std::placeholders::_1, std::placeholders::_2);*/

ASSERT_EQ(uuidEval("33355449-2c7d-43d7-967a-f53cd23215ad", "<", "ffffffff-ffff-ffff-ffff-ffffffffffff"), true);
ASSERT_EQ(uuidEval("33355449-2c7d-43d7-967a-f53cd23215ad", "<", "00000000-0000-0000-0000-000000000000"), false);
ASSERT_EQ(uuidEval("f768f36d-4f09-4da7-a298-3564d8f3c986", ">", "00000000-0000-0000-0000-000000000000"), true);
ASSERT_EQ(uuidEval("f768f36d-4f09-4da7-a298-3564d8f3c986", ">", "ffffffff-ffff-ffff-ffff-ffffffffffff"), false);

ASSERT_EQ(uuidEval("33355449-2c7d-43d7-967a-f53cd23215ad", "<=", "33355449-2c7d-43d7-967a-f53cd23215ad"), true);
ASSERT_EQ(uuidEval("33355449-2c7d-43d7-967a-f53cd23215ad", "<=", "ffffffff-ffff-ffff-ffff-ffffffffffff"), true);
ASSERT_EQ(uuidEval("33355449-2c7d-43d7-967a-f53cd23215ad", ">=", "33355449-2c7d-43d7-967a-f53cd23215ad"), true);
ASSERT_EQ(uuidEval("ffffffff-ffff-ffff-ffff-ffffffffffff", ">=", "33355449-2c7d-43d7-967a-f53cd23215ad"), true);

ASSERT_EQ(uuidEval("f768f36d-4f09-4da7-a298-3564d8f3c986", "==", "f768f36d-4f09-4da7-a298-3564d8f3c986"), true);
ASSERT_EQ(uuidEval("eed9f812-4b0c-472f-8a10-4ae7bff79a47", "!=", "f768f36d-4f09-4da7-a298-3564d8f3c986"), true);

ASSERT_EQ(uuidEval("11000000-0000-0022-0000-000000000000", "<", "22000000-0000-0011-0000-000000000000"), true);
ASSERT_EQ(uuidEval("00000000-0000-0000-2200-000000000011", ">", "00000000-0000-0000-1100-000000000022"), true);
ASSERT_EQ(uuidEval("00000000-0000-0000-0000-000000000011", ">", "22000000-0000-0000-0000-000000000000"), false);
ASSERT_EQ(uuidEval("11000000-0000-0000-0000-000000000000", "<", "00000000-0000-0000-0000-000000000022"), false);


/*auto data0 = makeFlatVector<std::string>({
"33355449-2c7d-43d7-967a-f53cd23215ad",
"33355449-2c7d-43d7-967a-f53cd23215ad",
});
auto data1 = makeFlatVector<std::string>({
"43355449-2c7d-43c7-967a-f53cd23215ad",
"23355449-2c7d-43e7-967a-f53cd23215ad",
});
auto actual = evaluate("cast(c0 as uuid) < cast(c1 as uuid)", makeRowVector({data0, data1}));
auto expected = makeFlatVector<bool>({true, false});
velox::test::assertEqualVectors(expected, actual);*/

/*
auto data0 = makeFlatVector<std::string>({
"33355449-2c7d-43d7-967a-f53cd23215ad",
"eed9f812-4b0c-472f-8a10-4ae7bff79a47",
Expand Down Expand Up @@ -149,7 +196,7 @@ TEST_F(UuidFunctionsTest, comparisons) {
actual = evaluate("cast(c0 as uuid) != cast(c1 as uuid)", makeRowVector({data0, data1}));
expected = makeFlatVector<bool>({true, true, true, true, true, false});
velox::test::assertEqualVectors(expected, actual);
velox::test::assertEqualVectors(expected, actual);*/
}

} // namespace
Expand Down

0 comments on commit 918598f

Please sign in to comment.