Skip to content

Commit dfd1817

Browse files
committed
TestCase instead of Test for derivative tests.
1 parent 6b1a2c7 commit dfd1817

File tree

2 files changed

+10
-45
lines changed

2 files changed

+10
-45
lines changed

MathExpressions.NET.Tests/MathFuncDerivativeTest.cs

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -71,51 +71,16 @@ public void UnknownFuncThirdDerivativeTest()
7171
Assert.IsTrue(derivative == "diff(diff(diff(f(x), x), x), x)");
7272
}
7373

74-
[Test]
75-
public void Derivative1()
76-
{
77-
string expression = "x ^ 3 + sin(3 * ln(x * 1)) + x ^ ln(2 * sin(3 * ln(x))) - 2 * x ^ 3";
78-
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, GetDerivativeExpression(expression)));
79-
}
80-
81-
[Test]
82-
public void Derivative2()
83-
{
84-
string expression = "x / sin(x) / cos(x) + ln(1 / sin(x))";
85-
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, GetDerivativeExpression(expression)));
86-
}
87-
88-
[Test]
89-
public void Derivative3()
90-
{
91-
string expression = "ln(sin(x ^ x))";
92-
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, GetDerivativeExpression(expression)));
93-
}
94-
95-
[Test]
96-
public void Derivative4()
97-
{
98-
string expression = "(2 * x ^ 2 - 1) / (2 * x ^ 2 + 1)";
99-
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, GetDerivativeExpression(expression)));
100-
}
101-
102-
[Test]
103-
public void Derivative5()
104-
{
105-
string expression = "tan(1 / x) / 3 ^ sin(x)";
106-
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, GetDerivativeExpression(expression)));
107-
}
108-
109-
[Test]
110-
public void Derivative6()
111-
{
112-
string expression = "atan(sqrt(x)) * ln(x)";
113-
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, GetDerivativeExpression(expression)));
114-
}
115-
116-
private string GetDerivativeExpression(string expression)
74+
[TestCase("x ^ 3 + sin(3 * ln(x * 1)) + x ^ ln(2 * sin(3 * ln(x))) - 2 * x ^ 3")]
75+
[TestCase("x / sin(x) / cos(x) + ln(1 / sin(x))")]
76+
[TestCase("ln(sin(x ^ x))")]
77+
[TestCase("(2 * x ^ 2 - 1) / (2 * x ^ 2 + 1)")]
78+
[TestCase("tan(1 / x) / 3 ^ sin(x)")]
79+
[TestCase("atan(sqrt(x)) * ln(x)")]
80+
public void CheckDerivativeWithWolframAlpha(string expression)
11781
{
118-
return new MathFunc(expression).GetDerivative().GetPrecompilied().ToString();
82+
var derivativeExpression = new MathFunc(expression).GetDerivative().GetPrecompilied().ToString();
83+
Assert.IsTrue(WolframAlphaUtils.CheckDerivative(expression, derivativeExpression));
11984
}
12085
}
12186
}

MathExpressions.NET.Tests/MiscTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void IntPowerTest()
1717
Assert.AreEqual(Math.Pow(i, j), IntPow(i, j));
1818
}
1919

20-
int IntPow(int x, int pow)
20+
private int IntPow(int x, int pow)
2121
{
2222
int ret = x;
2323

0 commit comments

Comments
 (0)