Line data Source code
1 : #include "../../inc/parsingAnalysis/builder.h"
2 : #include <catch2/catch_test_macros.hpp>
3 : #include <memory>
4 :
5 : using namespace nicole;
6 :
7 9 : TEST_CASE("AST_BINARY class methods", "[AST_BINARY]") {
8 9 : Location loc{"file", 0, 0};
9 9 : Token token{TokenType::OPERATOR_ADD, "+", loc};
10 9 : auto leftOperand = *Builder::createInt(SourceLocation{token, token}, 21);
11 9 : auto rightOperand = *Builder::createInt(SourceLocation{token, token}, 21);
12 9 : AST_BINARY astAdd{0, SourceLocation{token, token}, token, leftOperand, rightOperand};
13 :
14 9 : REQUIRE(astAdd.op().raw() == "+");
15 9 : REQUIRE(astAdd.left() == leftOperand);
16 9 : REQUIRE(astAdd.right() == rightOperand);
17 9 : REQUIRE(std::dynamic_pointer_cast<AST_INT>(astAdd.left())->value() == 21);
18 9 : REQUIRE(std::dynamic_pointer_cast<AST_INT>(astAdd.right())->value() == 21);
19 9 : }
|