From da226f7861669077aa41d9f5aa118a8535dfc9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 11 Oct 2018 16:43:00 +0200 Subject: [PATCH] [tests] Fix GlobalContext namespace and duplicate test --- apps/calculation/test/calculation_store.cpp | 4 ++-- apps/sequence/test/sequence.cpp | 4 ++-- apps/solver/test/equation_store.cpp | 6 +++--- poincare/Makefile | 1 + poincare/test/addition.cpp | 4 ++-- poincare/test/float.cpp | 4 ++-- poincare/test/function.cpp | 4 ++-- poincare/test/helper.cpp | 6 +++--- poincare/test/properties.cpp | 10 +++++----- poincare/test/store.cpp | 9 --------- 10 files changed, 22 insertions(+), 30 deletions(-) diff --git a/apps/calculation/test/calculation_store.cpp b/apps/calculation/test/calculation_store.cpp index d67bceb8c..0bf6b24b3 100644 --- a/apps/calculation/test/calculation_store.cpp +++ b/apps/calculation/test/calculation_store.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include "../calculation_store.h" @@ -14,7 +14,7 @@ void assert_store_is(CalculationStore * store, const char * result[10]) { } QUIZ_CASE(calculation_store) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; CalculationStore store; quiz_assert(CalculationStore::k_maxNumberOfCalculations == 10); for (int i = 0; i < CalculationStore::k_maxNumberOfCalculations; i++) { diff --git a/apps/sequence/test/sequence.cpp b/apps/sequence/test/sequence.cpp index 4ab4e7fd3..1f2f990b4 100644 --- a/apps/sequence/test/sequence.cpp +++ b/apps/sequence/test/sequence.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -11,7 +11,7 @@ using namespace Poincare; namespace Sequence { void check_sequences_defined_by(double result[2][10], Sequence::Type typeU, const char * definitionU, const char * conditionU1 = nullptr, const char * conditionU2 = nullptr, Sequence::Type typeV = Sequence::Type::Explicit, const char * definitionV = nullptr, const char * conditionV1 = nullptr, const char * conditionV2 = nullptr) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; SequenceStore store; SequenceContext sequenceContext(&globalContext, &store); diff --git a/apps/solver/test/equation_store.cpp b/apps/solver/test/equation_store.cpp index 5c5fcbcf2..98a68eeaf 100644 --- a/apps/solver/test/equation_store.cpp +++ b/apps/solver/test/equation_store.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -13,7 +13,7 @@ namespace Solver { void assert_equation_system_exact_solve_to(const char * equations[], EquationStore::Error error, EquationStore::Type type, const char * variables[], const char * solutions[], int numberOfSolutions) { char buffer[200]; - GlobalContext globalContext; + Shared::GlobalContext globalContext; EquationStore equationStore; int index = 0; while (equations[index] != 0) { @@ -49,7 +49,7 @@ void assert_equation_system_exact_solve_to(const char * equations[], EquationSto void assert_equation_approximate_solve_to(const char * equations, double xMin, double xMax, const char * variable, double solutions[], int numberOfSolutions, bool hasMoreSolutions) { char buffer[200]; - GlobalContext globalContext; + Shared::GlobalContext globalContext; EquationStore equationStore; Shared::ExpressionModel * e = equationStore.addEmptyModel(); strlcpy(buffer, equations, 200); diff --git a/poincare/Makefile b/poincare/Makefile index 71c3c3986..73badd9fa 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -167,6 +167,7 @@ tests += $(addprefix poincare/test/,\ ) test_objs += $(addprefix poincare/test/, tree/helpers.o) +test_objs += $(addprefix apps/shared/, global_context.o) # simplify_utils.cpp\ diff --git a/poincare/test/addition.cpp b/poincare/test/addition.cpp index ff188a971..3ff0b7db6 100644 --- a/poincare/test/addition.cpp +++ b/poincare/test/addition.cpp @@ -1,8 +1,8 @@ #include -#include #include #include #include +#include #include #include #include "helper.h" @@ -11,7 +11,7 @@ using namespace Poincare; static inline void assert_approximation_equals(const Expression i, float f) { - Poincare::GlobalContext c; + Shared::GlobalContext c; quiz_assert(i.approximateToScalar(c, Preferences::AngleUnit::Degree) == f); } diff --git a/poincare/test/float.cpp b/poincare/test/float.cpp index 501da60dd..95979cc9c 100644 --- a/poincare/test/float.cpp +++ b/poincare/test/float.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -13,7 +13,7 @@ using namespace Poincare; template void assert_float_evaluates_to(Float f, const char * result) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; int numberOfDigits = sizeof(T) == sizeof(double) ? PrintFloat::k_numberOfStoredSignificantDigits : PrintFloat::k_numberOfPrintedSignificantDigits; char buffer[500]; f.template approximate(globalContext, Radian, Cartesian).serialize(buffer, sizeof(buffer), DecimalMode, numberOfDigits); diff --git a/poincare/test/function.cpp b/poincare/test/function.cpp index 0b8020b2f..655daf404 100644 --- a/poincare/test/function.cpp +++ b/poincare/test/function.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -10,7 +10,7 @@ using namespace Poincare; template void assert_exp_is_bounded(Expression exp, T lowBound, T upBound, bool upBoundIncluded = false) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; T result = exp.approximateToScalar(globalContext, Radian); quiz_assert(result >= lowBound); quiz_assert(result < upBound || (result == upBound && upBoundIncluded)); diff --git a/poincare/test/helper.cpp b/poincare/test/helper.cpp index 7592fb40e..74406f7cb 100644 --- a/poincare/test/helper.cpp +++ b/poincare/test/helper.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -82,7 +82,7 @@ void assert_parsed_expression_is(const char * expression, Poincare::Expression r } void assert_parsed_expression_polynomial_degree(const char * expression, int degree, const char * symbolName) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; Expression e = parse_expression(expression); e = e.simplify(globalContext, Radian); quiz_assert(e.polynomialDegree(globalContext, symbolName) == degree); @@ -91,7 +91,7 @@ void assert_parsed_expression_polynomial_degree(const char * expression, int deg typedef Expression (*ProcessExpression)(Expression, Context & context, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat); void assert_parsed_expression_process_to(const char * expression, const char * result, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat, ProcessExpression process, int numberOfSignifiantDigits = PrintFloat::k_numberOfStoredSignificantDigits) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; Expression e = parse_expression(expression); #if POINCARE_TESTS_PRINT_EXPRESSIONS cout << " Entry expression: " << expression << "----" << endl; diff --git a/poincare/test/properties.cpp b/poincare/test/properties.cpp index b067639a1..5882544ba 100644 --- a/poincare/test/properties.cpp +++ b/poincare/test/properties.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -12,7 +12,7 @@ constexpr Poincare::ExpressionNode::Sign Negative = Poincare::ExpressionNode::Si constexpr Poincare::ExpressionNode::Sign Unknown = Poincare::ExpressionNode::Sign::Unknown; void assert_parsed_expression_sign(const char * expression, Poincare::ExpressionNode::Sign sign) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; Expression e = parse_expression(expression); quiz_assert(!e.isUninitialized()); e = e.simplify(globalContext, Degree); @@ -56,7 +56,7 @@ QUIZ_CASE(poincare_polynomial_degree) { } void assert_parsed_expression_has_characteristic_range(const char * expression, float range, Preferences::AngleUnit angleUnit = Preferences::AngleUnit::Degree) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; Expression e = parse_expression(expression); quiz_assert(!e.isUninitialized()); e = e.simplify(globalContext, angleUnit); @@ -86,7 +86,7 @@ void assert_parsed_expression_has_variables(const char * expression, const char quiz_assert(!e.isUninitialized()); constexpr static int k_maxVariableSize = 10; char variableBuffer[Expression::k_maxNumberOfVariables+1][k_maxVariableSize] = {{0}}; - GlobalContext globalContext; + Shared::GlobalContext globalContext; int numberOfVariables = e.getVariables(globalContext, [](const char * symbol) { return true; }, (char *)variableBuffer, k_maxVariableSize); quiz_assert(trueNumberOfVariables == numberOfVariables); if (numberOfVariables < 0) { @@ -116,7 +116,7 @@ QUIZ_CASE(poincare_get_variables) { } void assert_parsed_expression_has_polynomial_coefficient(const char * expression, const char * symbolName, const char ** coefficients, Preferences::AngleUnit angleUnit = Preferences::AngleUnit::Degree) { - GlobalContext globalContext; + Shared::GlobalContext globalContext; Expression e = parse_expression(expression); quiz_assert(!e.isUninitialized()); e = e.deepReduce(globalContext, angleUnit); diff --git a/poincare/test/store.cpp b/poincare/test/store.cpp index 1583723d4..1d63c4dff 100644 --- a/poincare/test/store.cpp +++ b/poincare/test/store.cpp @@ -23,15 +23,6 @@ QUIZ_CASE(poincare_store_simplify) { Ion::Storage::sharedStorage()->recordNamed("x.exp").destroy(); } -QUIZ_CASE(poincare_store_simplify) { - assert_parsed_expression_simplify_to("1+2>A", "A"); - assert_parsed_expression_simplify_to("1+2>x", "x"); - - // Clean the storage for other tests - Ion::Storage::sharedStorage()->recordNamed("A.exp").destroy(); - Ion::Storage::sharedStorage()->recordNamed("x.exp").destroy(); -} - QUIZ_CASE(poincare_store_user_variable) { // Fill variable assert_parsed_expression_simplify_to("1+2>Adadas", "Adadas");