示例#1
0
        public void PolynomialSetCoeffsTest()
        {
            Polynomial P1 = new Polynomial(3, new double[] { 1, 1, 2, 1 });
            double[] d;
            try
            {
                d = new double[] { 1, 2, 3, 4, 5 };
                P1.setCoeffs(d);
                Assert.Fail(); // If it gets to this line, no exception was thrown
            }
            catch (MathException) { }
            catch (Exception) { Assert.Fail(); }

            d = new double[] { 4, 2, 4, 2 };
            P1.setCoeffs(d);
            Polynomial P2 = new Polynomial(3, new double[] { 4, 2, 4, 2 });
            Assert.AreEqual(P1, P2);
            P1 = new Polynomial(3, new double[] { 1, 1, 2, 1 });
            d = new double[] { 4, 2, 4 };
            P2 = new Polynomial(3, new double[] { 4, 2, 4, 0 });
            P1.setCoeffs(d);
            Assert.AreEqual(P1, P2);
        }