Beispiel #1
0
        public virtual void test_hashCode()
        {
            DoublesPair a1 = DoublesPair.of(1d, 2.0d);
            DoublesPair a2 = DoublesPair.of(1d, 2.0d);

            assertEquals(a1.GetHashCode(), a2.GetHashCode());
        }
Beispiel #2
0
        //-------------------------------------------------------------------------
        public virtual void test_equals()
        {
            DoublesPair a  = DoublesPair.of(1d, 2.0d);
            DoublesPair a2 = DoublesPair.of(1d, 2.0d);
            DoublesPair b  = DoublesPair.of(1d, 3.0d);
            DoublesPair c  = DoublesPair.of(2d, 2.0d);
            DoublesPair d  = DoublesPair.of(2d, 3.0d);

            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);
        }
Beispiel #3
0
        public virtual void test_equals_bad()
        {
            DoublesPair a = DoublesPair.of(1.1d, 1.7d);

            assertEquals(a.Equals(null), false);
            assertEquals(a.Equals(ANOTHER_TYPE), false);
            object unrelatedPair = Pair.of(Convert.ToDouble(1.1d), Convert.ToDouble(1.7d));

            assertEquals(a.Equals(unrelatedPair), false);
        }
Beispiel #4
0
        //-------------------------------------------------------------------------
        public virtual void test_compareTo()
        {
            DoublesPair p12 = DoublesPair.of(1d, 2d);
            DoublesPair p13 = DoublesPair.of(1d, 3d);
            DoublesPair p21 = DoublesPair.of(2d, 1d);

            assertTrue(p12.CompareTo(p12) == 0);
            assertTrue(p12.CompareTo(p13) < 0);
            assertTrue(p12.CompareTo(p21) < 0);

            assertTrue(p13.CompareTo(p12) > 0);
            assertTrue(p13.CompareTo(p13) == 0);
            assertTrue(p13.CompareTo(p21) < 0);

            assertTrue(p21.CompareTo(p12) > 0);
            assertTrue(p21.CompareTo(p13) > 0);
            assertTrue(p21.CompareTo(p21) == 0);
        }
Beispiel #5
0
        public virtual void coverage()
        {
            DoublesPair test = DoublesPair.of(1d, 2.0d);

            TestHelper.coverImmutableBean(test);
        }