Skip to content

Commit

Permalink
Minor code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
peastman committed Nov 4, 2009
1 parent fb24990 commit 32f5e1d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tests/TestParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ class ExampleFunction : public CustomFunction {
return 2.0*arguments[1];
else if (derivOrder[1] == 1)
return 2.0;
else
return 0.0;
}
if (derivOrder[1] == 1) {
if (derivOrder[0] == 0)
return 2.0*arguments[0];
else
return 0.0;
}
if (derivOrder[1] == 1 && derivOrder[0] == 0)
return 2.0*arguments[0];
return 0.0;
}
CustomFunction* clone() const {
Expand Down Expand Up @@ -143,7 +137,8 @@ void verifyDerivative(const string& expression, const string& expectedDeriv) {

void testCustomFunction(const string& expression, const string& equivalent) {
map<string, CustomFunction*> functions;
functions["custom"] = new ExampleFunction();
ExampleFunction exp;
functions["custom"] = &exp;
ParsedExpression exp1 = Parser::parse(expression, functions);
ParsedExpression exp2 = Parser::parse(equivalent);
verifySameValue(exp1, exp2, 1.0, 2.0);
Expand All @@ -162,7 +157,6 @@ void testCustomFunction(const string& expression, const string& equivalent) {
verifySameValue(deriv3, deriv4, 2.0, 3.0);
verifySameValue(deriv3, deriv4, -2.0, 3.0);
verifySameValue(deriv3, deriv4, 2.0, -3.0);
delete functions["custom"];
}

int main() {
Expand Down

0 comments on commit 32f5e1d

Please sign in to comment.