From 07fdfacd5ba3069f6ceb6fffef536d9f9fb57037 Mon Sep 17 00:00:00 2001 From: Felix Raimundo Date: Mon, 11 Apr 2016 16:45:10 +0200 Subject: [PATCH] Adds the equivalentTo test utility. Change-Id: I1999a2e7434cc5919e628b906a13ec0edea04b8d --- poincare/test/simplify_utils.cpp | 23 +++++++++++++++++++++++ poincare/test/simplify_utils.h | 1 + 2 files changed, 24 insertions(+) diff --git a/poincare/test/simplify_utils.cpp b/poincare/test/simplify_utils.cpp index 7beb120f0..24187fd0e 100644 --- a/poincare/test/simplify_utils.cpp +++ b/poincare/test/simplify_utils.cpp @@ -64,3 +64,26 @@ bool identical_to(const char * input_string, const char * expected_string) { return isIdentical; } + +bool equivalent_to(const char * input_string, const char * expected_string) { + Expression * input = Expression::parse(input_string); + assert(input != nullptr); +#if POINCARE_TESTS_PRINT_EXPRESSIONS + cout << "Input = " << endl; + print_expression(input); +#endif + + Expression * expected = Expression::parse(expected_string); + assert(expected != nullptr); +#if POINCARE_TESTS_PRINT_EXPRESSIONS + cout << "Expected = " << endl; + print_expression(expected); +#endif + + bool isEquivalent = input->isEquivalentTo(expected); + + delete expected; + delete input; + + return isEquivalent; +} diff --git a/poincare/test/simplify_utils.h b/poincare/test/simplify_utils.h index 81598564d..28dd36297 100644 --- a/poincare/test/simplify_utils.h +++ b/poincare/test/simplify_utils.h @@ -6,5 +6,6 @@ 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); +bool equivalent_to(const char * input_string, const char * expected_string); #endif // POINCARE_TEST_SIMPLIFY_UTILS_H