mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2031 Curve Calculator : Sort variable names by the order they first appear
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
@@ -132,7 +134,12 @@ caf::PdmFieldHandle* RimCalculation::userDescriptionField()
|
||||
bool RimCalculation::parseExpression()
|
||||
{
|
||||
QString leftHandSideVariableName = RimCalculation::findLeftHandSide(m_expression);
|
||||
if (leftHandSideVariableName.isEmpty()) return false;
|
||||
if (leftHandSideVariableName.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(nullptr, "Expression Parser", "Failed to detect left hand side of equation");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<QString> variableNames = ExpressionParser::detectReferencedVariables(m_expression);
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ TEST(RicExpressionParserTest, DetectVariables)
|
||||
|
||||
std::vector<QString> variables = ExpressionParser::detectReferencedVariables(expr);
|
||||
|
||||
EXPECT_STREQ(variables[0].toStdString().data(), "a");
|
||||
EXPECT_STREQ(variables[1].toStdString().data(), "c");
|
||||
EXPECT_STREQ(variables[0].toStdString().data(), "c");
|
||||
EXPECT_STREQ(variables[1].toStdString().data(), "a");
|
||||
EXPECT_STREQ(variables[2].toStdString().data(), "x");
|
||||
EXPECT_STREQ(variables[3].toStdString().data(), "y");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user