diff --git a/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs b/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs index 47bd08708ebb665b61597486eb16b07c22ef1fc7..406737b20d19972289da036b0477172d1eff8084 100644 --- a/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs +++ b/VectoCore/VectoCoreTest/Utils/VectoMathTest.cs @@ -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