/** Unit test for Tuple.getField() and Tuple.setField() */
  @Test
  public void modifyFields() {
    TupleDesc td = Utility.getTupleDesc(2);

    Tuple tup = new Tuple(td);
    tup.setField(0, new IntField(-1));
    tup.setField(1, new IntField(0));

    assertEquals(new IntField(-1), tup.getField(0));
    assertEquals(new IntField(0), tup.getField(1));

    tup.setField(0, new IntField(1));
    tup.setField(1, new IntField(37));

    assertEquals(new IntField(1), tup.getField(0));
    assertEquals(new IntField(37), tup.getField(1));
  }
  @Test
  public void new_toStringTest() {
    int length = 10;
    String name = "td";
    Tuple t = new Tuple(Utility.getTupleDesc(length, name));
    for (int i = 0; i < length; i++) {
      t.setField(i, new TestField());
    }

    String tString = t.toString();

    // Last character should be \n.
    assertEquals("\n", tString.substring(tString.length() - 1));

    // Only last character is \n.
    assertFalse(tString.substring(0, tString.length() - 1).contains("\n"));

    // Split string on any white character.
    String[] tStringAr = tString.substring(0, tString.length() - 1).split("\\s+");
    assertEquals(length, tStringAr.length);
  }