#include #include #include #include #include #include "helper.h" using namespace Poincare; QUIZ_CASE(poincare_parser) { Complex a[1] = {Complex::Float(1.2*M_E)}; assert_parsed_expression_evaluates_to("1.2*X^(1)", a); Complex b[1] = {Complex::Float(std::pow((float)M_E, 2.0f)*M_E)}; assert_parsed_expression_evaluates_to("X^2*X^(1)", b); Complex c[1] = {Complex::Float(2.0*std::pow(3.0, 4.0)+2.0)}; assert_parsed_expression_evaluates_to("2*3^4+2", c); Complex d[1] = {Complex::Float(-2.0f*std::pow(3.0f, 4.0f)+2.0f)}; assert_parsed_expression_evaluates_to("-2*3^4+2", d); Complex e[1] = {Complex::Float(-std::sin(3.0)*2.0-3.0)}; assert_parsed_expression_evaluates_to("-sin(3)*2-3", e, Radian); Complex f[1] = {Complex::Float(-0.003f)}; assert_parsed_expression_evaluates_to("-.003", f); Complex g[1] = {Complex::Float(2.0)}; assert_parsed_expression_evaluates_to(".02E2", g); Complex h[1] = {Complex::Float(5.0f-2.0f/3.0f)}; assert_parsed_expression_evaluates_to("5-2/3", h); Complex i[1] = {Complex::Float(2.0/3.0-5.0)}; assert_parsed_expression_evaluates_to("2/3-5", i); Complex j[1] = {Complex::Float(-2.0f/3.0f-5.0f)}; assert_parsed_expression_evaluates_to("-2/3-5", j); Complex k[1] = {Complex::Float(std::sin(3.0)*2.0*(4.0+2.0))}; assert_parsed_expression_evaluates_to("sin(3)2(4+2)", k, Radian); Complex l[1] = {Complex::Float(4.0f/2.0f*(2.0f+3.0f))}; assert_parsed_expression_evaluates_to("4/2*(2+3)", l, Radian); Complex m[1] = {Complex::Float(4.0/2.0*(2.0+3.0))}; assert_parsed_expression_evaluates_to("4/2*(2+3)", m, Radian); }