PorygonLang/tests/TreeStringTests.cpp

32 lines
947 B
C++

#ifdef TESTS_BUILD
#include <catch.hpp>
#include <sstream>
#include "../src/Binder/BoundStatements/BoundStatement.hpp"
using namespace Porygon::Binder;
TEST_CASE( "Bad Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto s = new BoundBadStatement();
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tBadStatement");
delete s;
}
TEST_CASE( "Break Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto s = new BoundBreakStatement();
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tBreakStatement");
delete s;
}
TEST_CASE( "Block Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto s = new BoundBlockStatement({new BoundBreakStatement(), new BoundBreakStatement()});
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tBlockStatement\n\t\tBreakStatement\n\t\tBreakStatement");
delete s;
}
#endif