예제 #1
0
        public virtual void test_equals_bad()
        {
            Pair <int, string> a = Pair.of(1, "Hello");

            assertEquals(a.Equals(null), false);
            assertEquals(a.Equals(ANOTHER_TYPE), false);
        }
예제 #2
0
        //-------------------------------------------------------------------------
        public virtual void test_equals()
        {
            Pair <int, string> a  = Pair.of(1, "Hello");
            Pair <int, string> a2 = Pair.of(1, "Hello");
            Pair <int, string> b  = Pair.of(1, "Goodbye");
            Pair <int, string> c  = Pair.of(2, "Hello");
            Pair <int, string> d  = Pair.of(2, "Goodbye");

            assertEquals(a.Equals(a), true);
            assertEquals(a.Equals(b), false);
            assertEquals(a.Equals(c), false);
            assertEquals(a.Equals(d), false);
            assertEquals(a.Equals(a2), true);

            assertEquals(b.Equals(a), false);
            assertEquals(b.Equals(b), true);
            assertEquals(b.Equals(c), false);
            assertEquals(b.Equals(d), false);

            assertEquals(c.Equals(a), false);
            assertEquals(c.Equals(b), false);
            assertEquals(c.Equals(c), true);
            assertEquals(c.Equals(d), false);

            assertEquals(d.Equals(a), false);
            assertEquals(d.Equals(b), false);
            assertEquals(d.Equals(c), false);
            assertEquals(d.Equals(d), true);
        }