@Test
public void testAddField() {

	try {
		// Add a value to an empty record
		Record record = new Record();
		assertTrue(record.getNumFields() == 0);
		record.addField(this.origVal1);
		assertTrue(record.getNumFields() == 1);
		assertTrue(origVal1.getValue().equals(record.getField(0, StringValue.class).getValue()));
		
		// Add 100 random integers to the record
		record = new Record();
		for (int i = 0; i < 100; i++) {
			IntValue orig = new IntValue(this.rand.nextInt());
			record.addField(orig);
			IntValue rec = record.getField(i, IntValue.class);
			
			assertTrue(record.getNumFields() == i + 1);
			assertTrue(orig.getValue() == rec.getValue());
		}
		
		// Add 3 values of different type to the record
		record = new Record(this.origVal1, this.origVal2);
		record.addField(this.origVal3);
		
		assertTrue(record.getNumFields() == 3);
		
		StringValue recVal1 = record.getField(0, StringValue.class);
		DoubleValue recVal2 = record.getField(1, DoubleValue.class);
		IntValue recVal3 = record.getField(2, IntValue.class);
		
		assertTrue("The value of the first field has changed", recVal1.equals(this.origVal1));
		assertTrue("The value of the second field changed", recVal2.equals(this.origVal2));
		assertTrue("The value of the third field has changed", recVal3.equals(this.origVal3));
	} catch (Throwable t) {
		Assert.fail("Test failed due to an exception: " + t.getMessage());
	}
}