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

Add BinaryExpressionProcessor tests for shift binary operator

- only shift left is added by now since shift right operator has no
instance (yet?)
parent eebcb716
No related branches found
No related tags found
1 merge request!116Add tests for EmbeddedIDiscreteFunctionUtils
...@@ -44,6 +44,7 @@ add_executable (unit_tests ...@@ -44,6 +44,7 @@ add_executable (unit_tests
test_BinaryExpressionProcessor_comparison.cpp test_BinaryExpressionProcessor_comparison.cpp
test_BinaryExpressionProcessor_equality.cpp test_BinaryExpressionProcessor_equality.cpp
test_BinaryExpressionProcessor_logic.cpp test_BinaryExpressionProcessor_logic.cpp
test_BinaryExpressionProcessor_shift.cpp
test_BinaryOperatorMangler.cpp test_BinaryOperatorMangler.cpp
test_BiCGStab.cpp test_BiCGStab.cpp
test_BuildInfo.cpp test_BuildInfo.cpp
......
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include <test_BinaryExpressionProcessor_utils.hpp>
#include <fstream>
#include <unistd.h>
// clazy:excludeall=non-pod-global-static
TEST_CASE("BinaryExpressionProcessor shift", "[language]")
{
SECTION("<<")
{
std::filesystem::path path = std::filesystem::temp_directory_path();
path.append(std::string{"binary_expression_processor_"} + std::to_string(getpid()));
std::string filename = path.string();
{
std::ostringstream data;
data << "let fout:ostream, fout = ofstream(\"" << path.string() << "\");\n";
data << R"(fout << 2 << " " << true << " " << 2 + 3 << "\n";)";
TAO_PEGTL_NAMESPACE::string_input input{data.str(), "test.pgs"};
auto ast = ASTBuilder::build(input);
ASTModulesImporter{*ast};
ASTNodeTypeCleaner<language::import_instruction>{*ast};
ASTSymbolTableBuilder{*ast};
ASTNodeDataTypeBuilder{*ast};
ASTNodeDeclarationToAffectationConverter{*ast};
ASTNodeTypeCleaner<language::var_declaration>{*ast};
ASTNodeExpressionBuilder{*ast};
ExecutionPolicy exec_policy;
ast->execute(exec_policy);
}
REQUIRE(std::filesystem::exists(filename));
{
std::string file_content;
std::ifstream fin(filename.c_str());
do {
char c = fin.get();
if (c != EOF) {
file_content += c;
}
} while (fin);
REQUIRE(file_content == "2 true 5\n");
}
std::filesystem::remove(filename);
REQUIRE(not std::filesystem::exists(filename));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment