public void PointMultiplicationInt() { var a = new Point <int>(2, 2); var b = new Point <int>(4, 4); Assert.AreEqual(PointUtil.Multiply(a, b), new Point <int>(8, 8)); Assert.AreEqual(PointUtil.Multiply(b, 2), new Point <int>(8, 8)); }
public void PointMultiplicationFloat() { var a = new Point <float>(.2f, .2f); var b = new Point <float>(4, 4); Assert.AreEqual(PointUtil.Multiply(a, b), new Point <float>(.8f, .8f)); Assert.AreEqual(PointUtil.Multiply(a, 4), new Point <float>(.8f, .8f)); }
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)); }