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