static void Main(string[] args) { var result = QuadricEquation.Solve(1, -2, -3); if (result[1] == -1 && result[0] == 3) { Console.WriteLine("PASS"); } else { Console.WriteLine("FAIL"); } }
static void Main(string[] args) { var a = double.Parse(Console.ReadLine()); var b = double.Parse(Console.ReadLine()); var c = double.Parse(Console.ReadLine()); var result = QuadricEquation.Solve(a, b, c); Console.WriteLine(result[0]); Console.WriteLine(result[1]); Console.ReadKey(); }
void Test(double a, double b, double c, int length, double x1, double x2) { var result = QuadricEquation.Solve(a, b, c); Assert.AreEqual(length, result.Length); if (length > 0) { Assert.AreEqual(result[0], x1); } if (length > 1) { Assert.AreEqual(result[1], x2); } }
void Test(double A, double B, double C, int length, double x1, double x2) { var result = QuadricEquation.Solve(A, B, C); Assert.AreEqual(length, result.Length); if (length > 0) { Assert.AreEqual(result[0], x1); } if (length > 1) { Assert.AreEqual(result[1], x2); } }
public void FunctionalTest() { var rnd = new Random(1); for (int i = 0; i < 100; i++) { var a = rnd.NextDouble() * 10; var b = rnd.NextDouble() * 10; var c = rnd.NextDouble() * 10; var solution = QuadricEquation.Solve(a, b, c); for (int j = 0; j < solution.Length; j++) { Assert.AreEqual(0, a * solution[j] * solution[j] + b * solution[j] + c, 10e-6); } } }