public void addField(Value value) {
        final int num = this.numFields;
        setNumFields(num + 1);
        internallySetField(num, value);
    }
@Test
    void testAddField() {
        // Add a value to an empty record
        Record record = new Record();
        assertThat(record.getNumFields()).isZero();
        record.addField(this.origVal1);
        assertThat(record.getNumFields()).isOne();
        assertThat(record.getField(0, StringValue.class).getValue())
                .as("The value of the first field has changed")
                .isEqualTo(origVal1.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);

            assertThat(i + 1).isEqualTo(record.getNumFields());
            assertThat(rec.getValue()).isEqualTo(orig.getValue());
        }

        // Add 3 values of different type to the record
        record = new Record(this.origVal1, this.origVal2);
        record.addField(this.origVal3);

        assertThat(record.getNumFields()).isEqualTo(3);

        StringValue recVal1 = record.getField(0, StringValue.class);
        DoubleValue recVal2 = record.getField(1, DoubleValue.class);
        IntValue recVal3 = record.getField(2, IntValue.class);

        assertThat((Object) recVal1)
                .as("The value of the first field has changed")
                .isEqualTo(this.origVal1);
        assertThat(recVal2).as("The value of the second field changed").isEqualTo(this.origVal2);
        assertThat(recVal3).as("The value of the third field has changed").isEqualTo(this.origVal3);
    }