コード例 #1
0
        public void PointDivisionInt()
        {
            var a = new Point <int>(4, 4);
            var b = new Point <int>(2, 2);

            Assert.AreEqual(PointUtil.Divide(a, b), new Point <int>(2, 2));
            Assert.AreEqual(PointUtil.Divide(a, 2), new Point <int>(2, 2));
        }
コード例 #2
0
        public void PointDivisionFloat()
        {
            var a = new Point <float>(1, 1);
            var b = new Point <float>(2, 2);

            Assert.AreEqual(PointUtil.Divide(a, b), new Point <float>(.5f, .5f));
            Assert.AreEqual(PointUtil.Divide(a, 2), new Point <float>(.5f, .5f));
        }
コード例 #3
0
    static void TestPoint()
    {
        var a = new Point <int>(0, 0);
        var b = new Point <int>(2, 2);

        var c = new Point <float>(2.5f, 3.5f);
        var d = new Point <float>(1, 2);

        Console.WriteLine("IEquatable (should be true): " + (new Point <int>(2, 2) == b));
        Console.WriteLine("IEquatable (should be false): " + (a == b));
        Console.WriteLine("Copy (should be true): " + (new Point <int>(b) == b));
        Console.WriteLine("Addition ({0}) ({1})", PointUtil.Add(a, b), PointUtil.Add(c, d));
        Console.WriteLine("Addition ({0}) ({1})", PointUtil.Add(a, 3), PointUtil.Add(c, 3.5f));
        Console.WriteLine("Subtraction ({0}) ({1})", PointUtil.Subtract(a, b), PointUtil.Subtract(c, d));
        Console.WriteLine("Subtraction ({0}) ({1})", PointUtil.Subtract(a, 3), PointUtil.Subtract(c, 3.5f));
        Console.WriteLine("Multiplication ({0}) ({1})", PointUtil.Multiply(a, b), PointUtil.Multiply(c, d));
        Console.WriteLine("Multiplication ({0}) ({1})", PointUtil.Multiply(b, 3), PointUtil.Multiply(c, 3));
        Console.WriteLine("Division ({0}) ({1})", PointUtil.Divide(b, b), PointUtil.Divide(c, d));
        Console.WriteLine("Division ({0}) ({1})", PointUtil.Divide(b, 2), PointUtil.Divide(c, 10));
    }