#include "expression.hpp" #include "print.hpp" #include #include template using term = boost::proto17::terminal; namespace bp17 = boost::proto17; TEST(print, test_print) { term unity{1.0}; int i_ = 42; term i{std::move(i_)}; bp17::expression< bp17::expr_kind::plus, term, term > expr = unity + std::move(i); bp17::expression< bp17::expr_kind::plus, term, bp17::expression< bp17::expr_kind::plus, term, term > > unevaluated_expr = unity + std::move(expr); { std::ostringstream oss; bp17::print(oss, unity); EXPECT_EQ(oss.str(), R"(term[=1] )"); } { std::ostringstream oss; bp17::print(oss, expr); EXPECT_EQ(oss.str(), R"(expr<+> term[=1] term[=42] )"); } { std::ostringstream oss; bp17::print(oss, unevaluated_expr); EXPECT_EQ(oss.str(), R"(expr<+> term[=1] expr<+> term[=1] term[=42] )"); } struct thing {}; term a_thing(thing{}); { std::ostringstream oss; bp17::print(oss, a_thing); EXPECT_EQ(oss.str(), R"(term[=<>] )"); } }