std::string Operator::get_prefix() const
{
std::stringstream concat{};
- concat << symbol << " " << lhs->get_postfix() << " " << rhs->get_postfix();
+ concat << symbol << " " << lhs->get_prefix() << " " << rhs->get_prefix();
return concat.str();
}
CHECK_THROWS( Exponent{my_n_double, my_double}.get_value() );
CHECK_THROWS( Exponent{zero, my_n_double}.get_value() );
}
+
+ SECTION("Compound Expressions")
+ {
+ Const_double my_double{2};
+ Const_double my_double_2{1.5};
+ Const_int my_int{3};
+ Const_int my_int_2{7};
+
+ Addition my_add{my_int, my_double};
+ Multiplication my_mult{my_int_2, my_double_2};
+ Exponent my_exp{my_add, my_mult};
+
+ CHECK( my_exp.get_postfix() == "3 2.000 + 7 1.500 * ^" );
+ CHECK( my_exp.get_infix() == "((3+2.000)^(7*1.500))" );
+ CHECK( my_exp.get_prefix() == "^ + 3 2.000 * 7 1.500" );
+ CHECK( my_exp.get_value() == 21836601.3427713849 );
+
+ }
}
int main()