[solver] Display warning when one of the variable name exceeds 10

characters
This commit is contained in:
Émilie Feral
2018-09-27 15:19:14 +02:00
parent c7bc22b5e2
commit 6113f97027
5 changed files with 12 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ public:
return false;
}
Poincare::Expression standardForm(Poincare::Context * context) const;
constexpr static int k_maxVariableSize = 10;
constexpr static int k_maxVariableSize = 11;
private:
void tidyStandardForm();
mutable Poincare::Expression m_standardForm;

View File

@@ -111,9 +111,9 @@ EquationStore::Error EquationStore::exactSolve(Poincare::Context * context) {
if (numberOfVariables == -1) {
return Error::TooManyVariables;
}
/*if (numberOfVariables == -2) {
if (numberOfVariables == -2) {
return Error::VariableNameTooLong;
}*/
}
}
/* 1- Linear System? */

View File

@@ -19,7 +19,8 @@ public:
EquationUndefined = -1,
TooManyVariables = -2,
NonLinearSystem = -3,
RequireApproximateSolution = -4
RequireApproximateSolution = -4,
VariableNameTooLong
};
/* EquationStore */
EquationStore();

View File

@@ -179,6 +179,9 @@ void ListController::resolveEquations() {
case EquationStore::Error::TooManyVariables:
app()->displayWarning(I18n::Message::TooManyVariables);
return;
case EquationStore::Error::VariableNameTooLong:
app()->displayWarning(I18n::Message::VariableNameTooLong);
return;
case EquationStore::Error::NonLinearSystem:
app()->displayWarning(I18n::Message::NonLinearSystem);
return;

View File

@@ -73,6 +73,10 @@ QUIZ_CASE(equation_solve) {
const char * equations0[] = {"x+y+z+a+b+c+d=0", 0};
assert_equation_system_exact_solve_to(equations0, EquationStore::Error::TooManyVariables, EquationStore::Type::LinearSystem, {""}, nullptr, 0);
// x+y+z+a+b+c+d = 0
const char * equations01[] = {"tototototot=0", 0};
assert_equation_system_exact_solve_to(equations0, EquationStore::Error::VariableNameTooLong, EquationStore::Type::VariableNameTooLong, {""}, nullptr, 0);
// x^2+y = 0
const char * equations1[] = {"x^2+y=0", 0};
assert_equation_system_exact_solve_to(equations1, EquationStore::Error::NonLinearSystem, EquationStore::Type::LinearSystem, {""}, nullptr, 0);