Esempio n. 1
0
        public void TestInvalid()
        {
            IGetSquareRoot sq = null;
            List <double>  roots;
            var            res = sq.GetSquareRoot(0d, 0d, 0d, out roots);

            Assert.AreEqual(SquareRootResultEnum.InvalidCoef, res);
            Assert.IsTrue(roots.Count == 0);
        }
Esempio n. 2
0
        public void TestNoRoots()
        {
            IGetSquareRoot sq = null;
            List <double>  roots;
            var            res = sq.GetSquareRoot(1d, 1d, 1d, out roots);

            Assert.AreEqual(SquareRootResultEnum.NoRoots, res);
            Assert.IsTrue(roots.Count == 0);
        }
Esempio n. 3
0
        public void TestOneRoot()
        {
            IGetSquareRoot sq = null;
            List <double>  roots;
            var            res = sq.GetSquareRoot(1d, -4d, 4d, out roots);

            Assert.AreEqual(SquareRootResultEnum.OneRoot, res);
            Assert.IsTrue(roots.Count == 1);
            Assert.IsTrue(CloseEnough(roots.First(), 2d, Double.Epsilon));
        }
Esempio n. 4
0
        public void TestTwoRoots()
        {
            IGetSquareRoot sq = null;
            List <double>  roots;
            var            res = sq.GetSquareRoot(1d, -2d, -3d, out roots);

            Assert.AreEqual(SquareRootResultEnum.TwoRoots, res);
            Assert.IsTrue(roots.Count == 2);
            Assert.IsTrue(CloseEnough(roots.First(), -1d, Double.Epsilon));
            Assert.IsTrue(CloseEnough(roots[1], 3d, Double.Epsilon));
        }