public void clear() {
        if (this.numFields > 0) {
            this.numFields = 0;
            this.firstModifiedPos = 0;
        }
    }
@Test
    void testClear() throws IOException {
        Record record = new Record(new IntValue(42));

        record.write(this.out);
        assertThat(record.getField(0, IntValue.class).getValue()).isEqualTo(42);

        record.setField(0, new IntValue(23));
        record.write(this.out);
        assertThat(record.getField(0, IntValue.class).getValue()).isEqualTo(23);

        record.clear();
        assertThat(record.getNumFields()).isZero();

        Record record2 = new Record(new IntValue(42));
        record2.read(in);
        assertThat(record2.getField(0, IntValue.class).getValue()).isEqualTo(42);
        record2.read(in);
        assertThat(record2.getField(0, IntValue.class).getValue()).isEqualTo(23);
    }