예제 #1
0
        public void TestUnorderedPairEquals()
        {
            IPair a = new UnorderedPair(1, 2);

            Assert.IsTrue(a.Equals(a));
            Assert.IsTrue(!a.Equals(null));
            IPair b = new UnorderedPair(1, 2);

            Assert.IsTrue(a.Equals(b));
            Assert.IsTrue(b.Equals(a));
            Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
            IPair c = new UnorderedPair(2, 1);

            Assert.IsTrue(a.Equals(c));
            Assert.IsTrue(c.Equals(a));
            Assert.IsTrue(a.GetHashCode() == c.GetHashCode());
        }
예제 #2
0
        public void TestInterPairEquals()
        {
            IPair a = new OrderedPair(1, 2);
            IPair b = new UnorderedPair(1, 2);

            Assert.IsTrue(!a.Equals(b));
            Assert.IsTrue(!b.Equals(a));
        }
예제 #3
0
        public void unordered_pair_pinning_test()
        {
            var pair1        = new UnorderedPair <Point>(new Point(0, 1), new Point(5, 5));
            var sameAsPair1  = new UnorderedPair <Point>(new Point(0, 1), new Point(5, 5));
            var p1           = new Point(5, 5);
            var p2           = new Point(0, 1);
            var pair1Flipped = new UnorderedPair <Point>(p1, p2);
            var pair2        = new UnorderedPair <Point>(new Point(0, -5), new Point(5, 5));

            Assert.True(pair1.Equals(pair1), "UnorderedPair.Equals works on self");
            Assert.True(pair1.Equals(sameAsPair1), "UnorderedPair.Equals works on identical set");
            Assert.True(pair1.Equals(pair1Flipped), "UnorderedPair.Equals works on flipped set");
            Assert.False(pair1.Equals(pair2), "UnorderedPair.Equals should be false for 2 different pairs");

            Assert.True(pair1 == sameAsPair1, "UnorderedPair == works on identical set");
            Assert.True(pair1 == pair1Flipped, "UnorderedPair == works on flipped set");
            Assert.False(pair1 == pair2, "UnorderedPair == should be false for 2 different pairs");
        }