Package com.opengamma.util.tuple

Examples of com.opengamma.util.tuple.IntDoublePair


*/
@Test(groups = TestGroup.UNIT)
public class IntDoublePairTest {

  public void test_IntDoublePair_of() {
    IntDoublePair test = IntDoublePair.of(1, 2.5d);
    assertEquals(new IntDoublePair(1, 2.5d), test);
  }
View Full Code Here


    IntDoublePair test = IntDoublePair.of(1, 2.5d);
    assertEquals(new IntDoublePair(1, 2.5d), test);
  }

  public void testConstructionGets() {
    IntDoublePair test = new IntDoublePair(1, 2.0d);
    assertEquals(Integer.valueOf(1), test.getFirst());
    assertEquals(Double.valueOf(2.0d), test.getSecond());
    assertEquals(1, test.getFirstInt());
    assertEquals(2.0d, test.getSecondDouble(), 1E-10);
    assertEquals(Integer.valueOf(1), test.getFirst());
    assertEquals(Double.valueOf(2.0d), test.getSecond());
    assertEquals(1, test.getFirstInt());
    assertEquals(2.0d, test.getSecondDouble(), 1E-10);
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Test(expectedExceptions = UnsupportedOperationException.class)
  public void testSetValue() {
    IntDoublePair pair = new IntDoublePair(2, -0.3d);
    pairToEntry(pair).setValue(Double.valueOf(1.2d));
  }
View Full Code Here

    pairToEntry(pair).setValue(Double.valueOf(1.2d));
  }

  @Test(expectedExceptions = UnsupportedOperationException.class)
  public void testSetValue_null() {
    IntDoublePair pair = new IntDoublePair(2, -0.3d);
    pairToEntry(pair).setValue(null);
  }
View Full Code Here

    pairToEntry(pair).setValue(null);
  }

  @Test(expectedExceptions = UnsupportedOperationException.class)
  public void testSetValue_primitives() {
    IntDoublePair pair = new IntDoublePair(2, -0.3d);
    pairToEntry(pair).setValue(1.2d);
  }
View Full Code Here

    pairToEntry(pair).setValue(1.2d);
  }

  //-------------------------------------------------------------------------
  public void compareTo() {
    IntDoublePair ab = Pair.of(1, 1.7d);
    IntDoublePair ac = Pair.of(1, 1.9d);
    IntDoublePair ba = Pair.of(2, 1.5d);

    FirstThenSecondPairComparator<Integer, Double> comparator = new FirstThenSecondPairComparator<Integer, Double>();
    assertTrue(comparator.compare(ab, ab) == 0);
    assertTrue(comparator.compare(ac, ab) > 0);
    assertTrue(comparator.compare(ba, ab) > 0);
View Full Code Here

    assertTrue(comparator.compare(ac, ba) < 0);
    assertTrue(comparator.compare(ba, ba) == 0);
  }

  public void testEquals() {
    IntDoublePair a = new IntDoublePair(1, 2.0);
    IntDoublePair b = new IntDoublePair(1, 3.0);
    IntDoublePair c = new IntDoublePair(2, 2.0);
    IntDoublePair d = new IntDoublePair(2, 3.0);
    assertEquals(true, a.equals(a));
    assertEquals(false, a.equals(b));
    assertEquals(false, a.equals(c));
    assertEquals(false, a.equals(d));

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

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

    assertEquals(false, d.equals(a));
    assertEquals(false, d.equals(b));
    assertEquals(false, d.equals(c));
    assertEquals(true, d.equals(d));
  }
View Full Code Here

    assertEquals(false, d.equals(c));
    assertEquals(true, d.equals(d));
  }

  public void testEquals_toObjectVersion() {
    IntDoublePair a = Pair.of(1, 1.7d);
    Pair<Integer, Double> b = Pair.of(Integer.valueOf(1), Double.valueOf(1.7d));
    assertEquals(true, a.equals(b));
    assertEquals(true, b.equals(a));
  }
View Full Code Here

    assertEquals(true, b.equals(a));
  }

  public void testEquals_toObjectVersion_null() {
    Pair<Integer, Double> a = Pair.of(null, Double.valueOf(1.9d));
    IntDoublePair b = Pair.of(1, 1.7d);
    assertEquals(true, a.equals(a));
    assertEquals(false, a.equals(b));
    assertEquals(false, b.equals(a));
    assertEquals(true, b.equals(b));
  }
View Full Code Here

    assertEquals(false, b.equals(a));
    assertEquals(true, b.equals(b));
  }

  public void testHashCode() {
    IntDoublePair a = Pair.of(1, 1.7d);
    Pair<Integer, Double> b = Pair.of(Integer.valueOf(1), Double.valueOf(1.7d));
    assertEquals(a.hashCode(), b.hashCode());
  }
View Full Code Here

TOP

Related Classes of com.opengamma.util.tuple.IntDoublePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.