Assert.assertTrue(exceptionThrown);
}
@Test
public void testCompareIntAttribute() {
Tuple t1 = new Tuple();
t1.addAttribute("1");
t1.addAttribute("2");
t1.addAttribute("112315412");
t1.addAttribute(Integer.MAX_VALUE+"");
t1.addAttribute("-1");
t1.addAttribute(Integer.MIN_VALUE+"");
// check identical values
Assert.assertTrue(t1.compareIntAttribute(t1, 0, 0) == 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 1, 1) == 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 2, 2) == 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 3, 3) == 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 4, 4) == 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 5, 5) == 0);
// check unequal values
Assert.assertTrue(t1.compareIntAttribute(t1, 0, 1) < 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 1, 0) > 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 1, 2) < 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 2, 1) > 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 2, 3) < 0);
// check negative values
Assert.assertTrue(t1.compareIntAttribute(t1, 0, 4) > 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 4, 0) < 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 4, 5) > 0);
Assert.assertTrue(t1.compareIntAttribute(t1, 5, 4) < 0);
// check for non-existing attributes
boolean exceptionThrown = false;
try {
t1.compareIntAttribute(t1, 0, 6);
} catch(IndexOutOfBoundsException ioobe) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
exceptionThrown = false;
try {
t1.compareIntAttribute(t1, 7, 0);
} catch(IndexOutOfBoundsException ioobe) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
}