- Main Page
- Classes
- Files

- File List

# C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/Tests/UnitTestBicubic.cs

    00001 ﻿
    00002 namespace Tests
    00003 {
    00004     using System;
    00005     using Microsoft.VisualStudio.TestTools.UnitTesting;
    00006     using NewGamePhysics.Mathematics;
    00007
    00011     [TestClass]
    00012     public class UnitTestBicubic
    00013     {
    00014         public UnitTestBicubic()
    00015         {
    00016         }
    00017
    00018         private TestContext testContextInstance;
    00019
    00024         public TestContext TestContext
    00025         {
    00026             get
    00027             {
    00028                 return testContextInstance;
    00029             }
    00030             set
    00031             {
    00032                 testContextInstance = value;
    00033             }
    00034         }
    00035
    00036         #region Additional test attributes
    00037         //
    00038         // You can use the following additional attributes as you write your tests:
    00039         //
    00040         // Use ClassInitialize to run code before running the first test in the class
    00041         // [ClassInitialize()]
    00042         // public static void MyClassInitialize(TestContext testContext) { }
    00043         //
    00044         // Use ClassCleanup to run code after all tests in a class have run
    00045         // [ClassCleanup()]
    00046         // public static void MyClassCleanup() { }
    00047         //
    00048         // Use TestInitialize to run code before running each test
    00049         // [TestInitialize()]
    00050         // public void MyTestInitialize() { }
    00051         //
    00052         // Use TestCleanup to run code after each test has run
    00053         // [TestCleanup()]
    00054         // public void MyTestCleanup() { }
    00055         //
    00056         #endregion
    00057
    00058         [TestMethod]
    00059         public void BicubicInterpolationZero()
    00060         {
    00061             double[,] G = {{0.0, 0.0, 0.0, 0.0},
    00062                            {0.0, 0.0, 0.0, 0.0},
    00063                            {0.0, 0.0, 0.0, 0.0},
    00064                            {0.0, 0.0, 0.0, 0.0}};
    00065
    00066             Bicubic bicubic = new Bicubic(G);
    00067             double g;
    00068             g = bicubic.Calc(0.0, 0.0);
    00069             Assert.AreEqual(0.0, g);
    00070             g = bicubic.Calc(1.0, 0.0);
    00071             Assert.AreEqual(0.0, g);
    00072             g = bicubic.Calc(0.0, 1.0);
    00073             Assert.AreEqual(0.0, g);
    00074             g = bicubic.Calc(1.0, 1.0);
    00075             Assert.AreEqual(0.0, g);
    00076
    00077             g = bicubic.Calc(0.5, 0.5);
    00078             Assert.AreEqual(0.0, g);
    00079         }
    00080
    00081         [TestMethod]
    00082         public void BicubicInterpolationOne()
    00083         {
    00084             double[,] G = {{1.0, 1.0, 1.0, 1.0},
    00085                            {1.0, 1.0, 1.0, 1.0},
    00086                            {1.0, 1.0, 1.0, 1.0},
    00087                            {1.0, 1.0, 1.0, 1.0}};
    00088
    00089             Bicubic bicubic = new Bicubic(G);
    00090             double g;
    00091             g = bicubic.Calc(0.0, 0.0);
    00092             Assert.AreEqual(1.0, g);
    00093             g = bicubic.Calc(1.0, 0.0);
    00094             Assert.AreEqual(1.0, g);
    00095             g = bicubic.Calc(0.0, 1.0);
    00096             Assert.AreEqual(1.0, g);
    00097             g = bicubic.Calc(1.0, 1.0);
    00098             Assert.AreEqual(1.0, g);
    00099
    00100             g = bicubic.Calc(0.5, 0.5);
    00101             Assert.AreEqual(1.0, g);
    00102         }
    00103
    00104         [TestMethod]
    00105         public void BicubicInterpolationBox()
    00106         {
    00107             double[,] G = {{1.0, 1.0, 1.0, 1.0},
    00108                            {1.0, 0.0, 0.0, 1.0},
    00109                            {1.0, 0.0, 0.0, 1.0},
    00110                            {1.0, 1.0, 1.0, 1.0}};
    00111
    00112             Bicubic bicubic = new Bicubic(G);
    00113             double g;
    00114             g = bicubic.Calc(0.5, 0.5);
    00115             Assert.IsTrue(g <= 0.0);
    00116
    00117             g = bicubic.Calc(0.0, 0.0);
    00118             Assert.AreEqual(0.0, g);
    00119             g = bicubic.Calc(1.0, 0.0);
    00120             Assert.AreEqual(0.0, g);
    00121             g = bicubic.Calc(0.0, 1.0);
    00122             Assert.AreEqual(0.0, g);
    00123             g = bicubic.Calc(1.0, 1.0);
    00124             Assert.AreEqual(0.0, g);
    00125         }
    00126     }
    00127 }