コード例 #1
0
ファイル: TupleTest.java プロジェクト: edesiocs/eventrend
  public void testStaticExtremes() {
    Tuple min, max, result;

    min = new Tuple(1.0f, 1.5f);
    max = new Tuple(2.0f, 2.5f);

    result = Tuple.min(min, max);
    assertTrue(result.equals(min));
    assertNotSame(result, min);
    assertNotSame(result, max);

    result = Tuple.max(min, max);
    assertTrue(result.equals(max));
    assertNotSame(result, min);
    assertNotSame(result, max);

    Tuple one = new Tuple(2.0f, 4.0f);
    Tuple two = new Tuple(1.0f, 5.0f);

    result = Tuple.min(one, two);
    assertEquals(1.0f, result.x);
    assertEquals(4.0f, result.y);
    assertNotSame(result, min);
    assertNotSame(result, max);

    result = Tuple.max(one, two);
    assertEquals(2.0f, result.x);
    assertEquals(5.0f, result.y);
    assertNotSame(result, min);
    assertNotSame(result, max);
  }
コード例 #2
0
ファイル: TupleTest.java プロジェクト: edesiocs/eventrend
  public void testComparison() {
    Tuple same1, same2, less, greater;

    same1 = new Tuple(0.0f, 1.0f);
    same2 = new Tuple(0.0f, 1.0f);
    less = new Tuple(-1.0f, 1.0f);
    greater = new Tuple(1.0f, 1.0f);
    assertTrue(same1.equals(same2));
    assertFalse(same1.equals(less));
    assertFalse(same1.equals(greater));

    assertTrue(same1.compareTo(same2) == 0);
    assertTrue(same1.compareTo(greater) < 0);
    assertTrue(same1.compareTo(less) > 0);
  }
コード例 #3
0
ファイル: TupleTest.java プロジェクト: edesiocs/eventrend
  public void testTupleExtremes() {
    Tuple min, max, result;

    min = new Tuple(1.0f, 1.5f);
    max = new Tuple(2.0f, 2.5f);
    result = new Tuple();

    result.set(min);
    result.min(max);
    assertTrue(result.equals(min));

    result.set(min);
    result.max(max);
    assertTrue(result.equals(max));

    result.set(max);
    result.min(min);
    assertTrue(result.equals(min));

    result.set(max);
    result.max(min);
    assertTrue(result.equals(max));

    Tuple one = new Tuple(2.0f, 4.0f);
    Tuple two = new Tuple(1.0f, 5.0f);

    result.set(one);
    result.min(two);
    assertEquals(1.0f, result.x);
    assertEquals(4.0f, result.y);

    result.set(one);
    result.max(two);
    assertEquals(2.0f, result.x);
    assertEquals(5.0f, result.y);
  }