Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit d0fed5f5 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding testcases for cubic equation solver

parent 94764b27
No related branches found
No related tags found
No related merge requests found
......@@ -30,8 +30,11 @@
*/
using System;
using System.Linq;
using System.Windows.Forms.VisualStyles;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Org.BouncyCastle.Asn1;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils;
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
......@@ -90,5 +93,23 @@ namespace TUGraz.VectoCore.Tests.Utils
Assert.IsTrue(double.IsNaN(isy));
}
}
[TestCase(1, 2, 0, 5, new[] { -2.6906474480286136 }),
TestCase(5, -3, 2, 10, new[] { -1.0 }),
TestCase(5, -30, 2, 10, new[] { -0.5238756689475912, 0.6499388479175676, 5.873936821030023 })]
public void CubicSolverTest(double a, double b, double c, double d, double[] expected)
{
var results = VectoMath.CubicEquationSolver(a, b, c, d);
Assert.AreEqual(expected.Length, results.Count);
var sorted = expected.ToList();
sorted.Sort();
results.Sort();
var comparison = sorted.Zip(results, (exp, result) => exp - result);
foreach (var cmp in comparison) {
Assert.AreEqual(0, cmp, 1e-15);
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment