[poincare] Repair tests

Change-Id: Ie14d3c1afc0c8e66d4b0eddb2919958391c5c959
This commit is contained in:
Émilie Feral
2017-09-26 16:38:22 +02:00
parent d12615ab8d
commit be1f2be60f
7 changed files with 27 additions and 42 deletions

View File

@@ -102,7 +102,7 @@ tests += $(addprefix poincare/test/,\
simplify_easy.cpp\
)
tests_orig += $(addprefix poincare/test/,\
tests += $(addprefix poincare/test/,\
addition.cpp\
complex.cpp\
division.cpp\

View File

@@ -32,16 +32,6 @@ void assert_parsed_expression_type(const char * expression, Poincare::Expression
delete e;
}
void assert_parsed_simplified_expression_type(const char * expression, Poincare::Expression::Type type) {
Expression * e = parse_expression(expression);
e->simplify();
//Expression * e2 = e->simplify();
//assert(e2);
assert(e->type() == type);
delete e;
//delete e2;
}
template<typename T>
void assert_parsed_expression_evaluates_to(const char * expression, Complex<T> * results, int numberOfRows, int numberOfColumns, Expression::AngleUnit angleUnit) {
GlobalContext globalContext;

View File

@@ -4,7 +4,6 @@ constexpr Poincare::Expression::AngleUnit Degree = Poincare::Expression::AngleUn
constexpr Poincare::Expression::AngleUnit Radian = Poincare::Expression::AngleUnit::Radian;
void assert_parsed_expression_type(const char * expression, Poincare::Expression::Type type);
void assert_parsed_simplified_expression_type(const char * expression, Poincare::Expression::Type type);
template<typename T>
void assert_parsed_expression_evaluates_to(const char * expression, Poincare::Complex<T> * results, int numberOfRows, int numberOfColumns = 1, Poincare::Expression::AngleUnit angleUnit = Degree);
template<typename T>

View File

@@ -29,8 +29,8 @@ QUIZ_CASE(poincare_identity_simple_term) {
}
QUIZ_CASE(poincare_identity_commutativity) {
assert(identical_to("1+2", "2+1"));
assert(equivalent_to("1+2", "2+1"));
//assert(identical_to("1*2", "2*1"));
assert(!identical_to("1-2", "2-1"));
assert(!identical_to("1/2", "2/1"));
assert(!equivalent_to("1-2", "2-1"));
assert(!equivalent_to("1/2", "2/1"));
}

View File

@@ -21,11 +21,10 @@ bool simplifies_to(const char * input_string, const char * expected_string) {
print_expression(input);
#endif
Expression * simplified = input->simplify();
assert(simplified != nullptr);
Expression::simplify(&input);
#if POINCARE_TESTS_PRINT_EXPRESSIONS
cout << "Simplified = " << endl;
print_expression(simplified);
print_expression(input);
#endif
Expression * expected = Expression::parse(expected_string);
@@ -35,10 +34,9 @@ bool simplifies_to(const char * input_string, const char * expected_string) {
print_expression(expected);
#endif
bool isIdentical = simplified->isIdenticalTo(expected);
bool isIdentical = input->compareTo(expected) == 0;
delete expected;
delete simplified;
delete input;
return isIdentical;
@@ -63,7 +61,7 @@ bool identical_to(const char * input_string, const char * expected_string) {
print_expression(expected);
#endif
bool isIdentical = input->isIdenticalTo(expected);
bool isIdentical = input->compareTo(expected) == 0;
delete expected;
delete input;
@@ -90,25 +88,21 @@ bool equivalent_to(const char * input_string, const char * expected_string) {
print_expression(expected);
#endif
Expression * simplified_input = input->simplify();
assert(simplified_input != nullptr);
Expression::simplify(&input);
#if POINCARE_TESTS_PRINT_EXPRESSIONS
cout << "Simplified Input = " << endl;
print_expression(simplified_input);
print_expression(input);
#endif
Expression * simplified_expected = Expression::parse(expected_string);
assert(simplified_expected != nullptr);
Expression::simplify(&expected);
#if POINCARE_TESTS_PRINT_EXPRESSIONS
cout << "Simplified Expected = " << endl;
print_expression(simplified_expected);
print_expression(expected);
#endif
bool isEquivalent = simplified_input->isIdenticalTo(simplified_expected);
bool isEquivalent = input->compareTo(expected) == 0;
delete expected;
delete input;
delete simplified_expected;
delete simplified_input;
return isEquivalent;
}

View File

@@ -6,6 +6,8 @@ bool simplifies_to(const char * input_string, const char * expected_string);
/* Tests that the first expression is identical to the second. */
bool identical_to(const char * input_string, const char * expected_string);
/* Tests that the first and the second expressions simplify to the same expression. */
bool equivalent_to(const char * input_string, const char * expected_string);
#endif // POINCARE_TEST_SIMPLIFY_UTILS_H

View File

@@ -7,18 +7,18 @@
using namespace Poincare;
QUIZ_CASE(poincare_parse_trigo) {
assert_parsed_simplified_expression_type("sin(0)", Expression::Type::Sine);
assert_parsed_simplified_expression_type("cos(0)", Expression::Type::Cosine);
assert_parsed_simplified_expression_type("tan(0)", Expression::Type::Tangent);
assert_parsed_simplified_expression_type("cosh(0)", Expression::Type::HyperbolicCosine);
assert_parsed_simplified_expression_type("sinh(0)", Expression::Type::HyperbolicSine);
assert_parsed_simplified_expression_type("tanh(0)", Expression::Type::HyperbolicTangent);
assert_parsed_simplified_expression_type("acos(0)", Expression::Type::ArcCosine);
assert_parsed_simplified_expression_type("asin(0)", Expression::Type::ArcSine);
assert_parsed_simplified_expression_type("atan(0)", Expression::Type::ArcTangent);
assert_parsed_simplified_expression_type("acosh(0)", Expression::Type::HyperbolicArcCosine);
assert_parsed_simplified_expression_type("asinh(0)", Expression::Type::HyperbolicArcSine);
assert_parsed_simplified_expression_type("atanh(0)", Expression::Type::HyperbolicArcTangent);
assert_parsed_expression_type("sin(0)", Expression::Type::Sine);
assert_parsed_expression_type("cos(0)", Expression::Type::Cosine);
assert_parsed_expression_type("tan(0)", Expression::Type::Tangent);
assert_parsed_expression_type("cosh(0)", Expression::Type::HyperbolicCosine);
assert_parsed_expression_type("sinh(0)", Expression::Type::HyperbolicSine);
assert_parsed_expression_type("tanh(0)", Expression::Type::HyperbolicTangent);
assert_parsed_expression_type("acos(0)", Expression::Type::ArcCosine);
assert_parsed_expression_type("asin(0)", Expression::Type::ArcSine);
assert_parsed_expression_type("atan(0)", Expression::Type::ArcTangent);
assert_parsed_expression_type("acosh(0)", Expression::Type::HyperbolicArcCosine);
assert_parsed_expression_type("asinh(0)", Expression::Type::HyperbolicArcSine);
assert_parsed_expression_type("atanh(0)", Expression::Type::HyperbolicArcTangent);
}
QUIZ_CASE(poincare_trigo_evaluate) {