示例#1
0
 public void PolynomialOperatorSquareBracketsTest()
 {
     Polynomial target = new Polynomial(3, new double[] {3,2,1,0});
     double expected = target[2];
     double actual = target.getValueAt(2);
     Assert.AreEqual(expected, actual);
     Assert.AreEqual(expected, (double)1);
     Assert.AreEqual(actual, (double)1);
     Assert.AreNotEqual(expected, (double)2);
 }
示例#2
0
 public void PolynomialGetValueTest()
 {
     Polynomial target = new Polynomial(3, new double[] { 3, 2, 1, 0 });
     Assert.IsTrue(target[2] == target.getValueAt(2));
     Assert.IsTrue(target.getValueAt(0) == (double)3);
     Assert.IsFalse(target.getValueAt(0) == target[2]);
     try
     {
         target.getValueAt(-1);
         Assert.Fail();
     }
     catch (MathException) { }
     catch (Exception) { Assert.Fail(); }
     try
     {
         target.getValueAt(6);
         Assert.Fail();
     }
     catch (MathException) { }
     catch (Exception) { Assert.Fail(); }
     try
     {
         double temp = target[-1];
         Assert.Fail();
     }
     catch (MathException) { }
     catch (Exception) { Assert.Fail(); }
     try
     {
         target[-1] = 6;
         Assert.Fail();
     }
     catch (MathException) { }
     catch (Exception) { Assert.Fail(); }
     try
     {
         double temp = target[6];
         Assert.Fail();
     }
     catch (MathException) { }
     catch (Exception) { Assert.Fail(); }
     try
     {
         target[6] = 6;
         Assert.Fail();
     }
     catch (MathException) { }
     catch (Exception) { Assert.Fail(); }
 }