using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnitTestSharp; using Azimuth.Polynomials; namespace Azimuth.UnitTests.Polynomials { public class QuarticTests : TestFixture { public void ZeroRootMult4() { RootList expected = new Scalar?[] { 0, 0, 0, 0 }; RootList actual = Quartic.Solve(1, 0, 0, 0, 0); CheckEqual(actual, expected); } public void TEST_Quartic_Correct() { RootList expected = new Scalar?[] { -1, 0, 1, 2 }; RootList actual = Quartic.Solve(1, -2, -1, 2, 0); CheckEqual(expected, actual); } public void TEST_Quartic_A0() { RootList expected = new Scalar?[] { -1, 0, 1 }; RootList actual = Quartic.Solve(0, 1, 0, -1, 0); CheckEqual(expected, actual); } public void TEST_Quartic_OnceCrashed() { RootList expected = new Scalar?[] { 1, -5.0/2 }; RootList actual = Quartic.Solve(-4, 0, 9, -30, 25); CheckEqual(expected, actual); } public void TEST_Quartic_NoSolutions() { RootList expected = new Scalar?[] { }; RootList actual = Quartic.Solve(32, 0, 60, 0, 25); CheckEqual(expected, actual); } public void TEST_Quartic_Quad_Roots_NonZero() { RootList expected = new Scalar?[] { 0, 0, 1, 1 }; RootList actual = Quartic.Solve(1, -2, 1, 0, 0); CheckEqual(expected, actual); } public void TEST_Quartic_Two_Roots_Same() { RootList expected = new Scalar?[] { 0, 0 }; RootList actual = Quartic.Solve(1, 0, 1, 0, 0); CheckEqual(expected, actual); } public void TEST_Quartic_Two_Roots_Different() { RootList expected = new Scalar?[] { 0, 1 }; RootList actual = Quartic.Solve(1, -1, 1, -1, 0); CheckEqual(expected, actual); } public void TEST_Quartic_Four_Roots_TwoDifferent() { RootList expected = new Scalar?[] { -1, 0, 0, 1 }; RootList actual = Quartic.Solve(1, 0, -1, 0, 0); CheckEqual(expected, actual); } public void TEST_Quartic_Four_Roots_Two_Groups_Of_Two() { RootList expected = new Scalar?[] { -1, -1, 1, 1 }; RootList actual = Quartic.Solve(1, 0, -2, 0, 1); CheckEqual(expected, actual); } public void RealSolutionsAllDifferent() { RootList expected = new Scalar?[] { -5, -4, 1, 2 }; RootList actual = Quartic.Solve(1, 6, -5, -42, 40); CheckEqual(expected, actual); } public void OnceGaveWrongResults() { RootList expected = new Scalar?[] { 1.0000000127, 1.9999999731, 17.000000024, 19.765065537 }; RootList actual = Quartic.Solve( 25.18051529, -1001.304841, 11288.45801, -27233.947788, 16921.6142 ); CheckEqual(expected, actual); } } }