Skip to content
Snippets Groups Projects
Commit b9b30bf1 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for UnaryOperatorMangler and BinaryOperatorMangler

parent 3211e05d
No related branches found
No related tags found
1 merge request!116Add tests for EmbeddedIDiscreteFunctionUtils
......@@ -44,6 +44,7 @@ add_executable (unit_tests
test_BinaryExpressionProcessor_comparison.cpp
test_BinaryExpressionProcessor_equality.cpp
test_BinaryExpressionProcessor_logic.cpp
test_BinaryOperatorMangler.cpp
test_BiCGStab.cpp
test_BuildInfo.cpp
test_BuiltinFunctionEmbedder.cpp
......@@ -102,6 +103,7 @@ add_executable (unit_tests
test_TinyVector.cpp
test_TupleToVectorProcessor.cpp
test_UnaryExpressionProcessor.cpp
test_UnaryOperatorMangler.cpp
test_Vector.cpp
test_WhileProcessor.cpp
)
......
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include <language/utils/BinaryOperatorMangler.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE("BinaryOperatorMangler", "[language]")
{
SECTION("binary operators")
{
const ASTNodeDataType R = ASTNodeDataType::build<ASTNodeDataType::double_t>();
const ASTNodeDataType Z = ASTNodeDataType::build<ASTNodeDataType::int_t>();
REQUIRE(binaryOperatorMangler<language::multiply_op>(R, Z) == "R * Z");
REQUIRE(binaryOperatorMangler<language::divide_op>(R, Z) == "R / Z");
REQUIRE(binaryOperatorMangler<language::plus_op>(R, Z) == "R + Z");
REQUIRE(binaryOperatorMangler<language::minus_op>(R, Z) == "R - Z");
REQUIRE(binaryOperatorMangler<language::or_op>(R, Z) == "R or Z");
REQUIRE(binaryOperatorMangler<language::and_op>(R, Z) == "R and Z");
REQUIRE(binaryOperatorMangler<language::xor_op>(R, Z) == "R xor Z");
REQUIRE(binaryOperatorMangler<language::greater_op>(R, Z) == "R > Z");
REQUIRE(binaryOperatorMangler<language::greater_or_eq_op>(R, Z) == "R >= Z");
REQUIRE(binaryOperatorMangler<language::lesser_op>(R, Z) == "R < Z");
REQUIRE(binaryOperatorMangler<language::lesser_or_eq_op>(R, Z) == "R <= Z");
REQUIRE(binaryOperatorMangler<language::eqeq_op>(R, Z) == "R == Z");
REQUIRE(binaryOperatorMangler<language::not_eq_op>(R, Z) == "R != Z");
REQUIRE(binaryOperatorMangler<language::shift_left_op>(R, Z) == "R << Z");
REQUIRE(binaryOperatorMangler<language::shift_right_op>(R, Z) == "R >> Z");
}
}
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include <language/utils/UnaryOperatorMangler.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE("UnaryOperatorMangler", "[language]")
{
SECTION("unary operators")
{
const ASTNodeDataType Z = ASTNodeDataType::build<ASTNodeDataType::int_t>();
REQUIRE(unaryOperatorMangler<language::unary_minus>(Z) == "- Z");
REQUIRE(unaryOperatorMangler<language::unary_not>(Z) == "not Z");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment