diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5902fa80c022ef4efea13be21c6865ad32204df1..f99ebffec64c8142a222956d43cafff8949e62da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 ) diff --git a/tests/test_BinaryOperatorMangler.cpp b/tests/test_BinaryOperatorMangler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..329c59dcb9fd5fadfae97f39dcbb9e7a6ee3e582 --- /dev/null +++ b/tests/test_BinaryOperatorMangler.cpp @@ -0,0 +1,31 @@ +#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"); + } +} diff --git a/tests/test_UnaryOperatorMangler.cpp b/tests/test_UnaryOperatorMangler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c533e882a445818923e0b7bd3719051eb5db8867 --- /dev/null +++ b/tests/test_UnaryOperatorMangler.cpp @@ -0,0 +1,17 @@ +#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"); + } +}