}
@Test
public void testGetLongValueAt() {
Tuple t = new Tuple();
long[] testVals = {0,1,2,1234123,-1,-1212312, Long.MIN_VALUE, Long.MAX_VALUE};
for(long testVal : testVals) {
t.addAttribute(testVal+"");
}
// check for same value
for(int i=0;i<testVals.length;i++) {
Assert.assertTrue(t.getLongValueAt(i) == testVals[i]);
}
// check for out-of-bounds values
boolean exceptionThrown = false;
try {
t.getLongValueAt(-1);
} catch(IndexOutOfBoundsException ioobe) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
exceptionThrown = false;
try {
t.getLongValueAt(testVals.length);
} catch(IndexOutOfBoundsException ioobe) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
exceptionThrown = false;
try {
t.getLongValueAt(testVals.length+1);
} catch(IndexOutOfBoundsException ioobe) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
// check for invalid format exception
t.addAttribute("abc");
exceptionThrown = false;
try {
t.getLongValueAt(testVals.length);
} catch(NumberFormatException nfe) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);