#include #include #include #include #include "helper.h" using namespace Poincare; QUIZ_CASE(poincare_addition_evaluate) { Complex a[1] = {Complex::Float(3.0f)}; assert_parsed_expression_evaluates_to("1+2", a); Complex b[1] = {Complex::Cartesian(6.0, 2.0)}; assert_parsed_expression_evaluates_to("2+I+4+I", b); #if MATRICES_ARE_DEFINED Complex c[6] = {Complex::Float(4.0f), Complex::Float(5.0f), Complex::Float(6.0f), Complex::Float(7.0f), Complex::Float(8.0f), Complex::Float(9.0f)}; assert_parsed_expression_evaluates_to("[[1,2][3,4][5,6]]+3", c, 3, 2); Complex d[6] = {Complex::Cartesian(4.0, 1.0), Complex::Cartesian(5.0, 2.0), Complex::Cartesian(6.0, 1.0), Complex::Cartesian(7.0, 1.0), Complex::Cartesian(8.0, 1.0), Complex::Cartesian(9.0, 1.0)}; assert_parsed_expression_evaluates_to("[[1,2+I][3,4][5,6]]+3+I", d, 3, 2); assert_parsed_expression_evaluates_to("3+[[1,2][3,4][5,6]]", c, 3, 2); assert_parsed_expression_evaluates_to("3+I+[[1,2+I][3,4][5,6]]", d, 3, 2); Complex e[6] = {Complex::Float(2.0f), Complex::Float(4.0f), Complex::Float(6.0f), Complex::Float(8.0f), Complex::Float(10.0f), Complex::Float(12.0f)}; assert_parsed_expression_evaluates_to("[[1,2][3,4][5,6]]+[[1,2][3,4][5,6]]", e, 3, 2); Complex f[6] = {Complex::Cartesian(2.0, 0.0), Complex::Cartesian(4.0, 2.0), Complex::Cartesian(6.0, 0.0), Complex::Cartesian(8.0, 0.0), Complex::Cartesian(10.0, 0.0), Complex::Cartesian(12.0, 0.0)}; assert_parsed_expression_evaluates_to("[[1,2+I][3,4][5,6]]+[[1,2+I][3,4][5,6]]", f, 3, 2); #endif }