Beispiel #1
0
        public void Vect2fSwizzleTest()
        {
            var v = new Vect2f(5, 6);

            Assert.AreEqual(new Vect2f(6, 6), v.Swizzle().YY);
            Assert.AreEqual(new Vect2f(5, 5), v.Swizzle().XX);
        }
Beispiel #2
0
        public void LengthResult()
        {
            var v2 = new Vect2f(2.0f, 3.0f);

            Assert.AreEqual(13.0, v2.LengthSquared, Constants.Delta);
            Assert.AreEqual(3.60555124282837, v2.Length, Constants.Delta);
        }
Beispiel #3
0
        public static dynamic Swizzle(this Vect2f v)
        {
            var s = new Swizzle <float>();

            s.Add('X', v.X);
            s.Add('Y', v.Y);
            return(s);
        }
Beispiel #4
0
        public void CreationFromList()
        {
            var x  = 2.0f;
            var y  = 3.0f;
            var v2 = new Vect2f(new[] { x, y });

            Assert.AreEqual(x, v2.X, Constants.Delta);
            Assert.AreEqual(y, v2.Y, Constants.Delta);
        }
Beispiel #5
0
        public void CreationFromDoubles()
        {
            var x  = 2.0f;
            var y  = 3.0f;
            var v2 = new Vect2f(x, y);

            Assert.AreEqual(x, v2.X, Constants.Delta);
            Assert.AreEqual(y, v2.Y, Constants.Delta);
        }
Beispiel #6
0
 public void CreationFromListTooLong()
 {
     try
     {
         var v = new Vect2f(new[] { 2.0f, 3.0f, 5.0f });
         Assert.Fail(); // If it gets to this line, no exception was thrown
     }
     catch (ArgumentException)
     {
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
Beispiel #7
0
        public void Equality()
        {
            var a = new Vect2f(2.0f, 3.0f);
            var b = new Vect2f(2.0f, 3.0f);
            var c = new Vect2f(3.0f, 4.0f);
            var d = a;

            Assert.IsTrue(a.Equals(b));
            Assert.IsFalse(a.Equals(c));
            Assert.IsTrue(a.Equals(d));
            Assert.AreEqual(a, b);
            Assert.AreNotEqual(a, c);
            Assert.AreEqual(a, d);
            Assert.IsTrue(a == b);
            Assert.IsTrue(a != c);
            Assert.IsTrue(a != null);
        }