public SerializationTester assertMatch(Identifiable expectedObject) throws IOException {
            // Ignore assert if we are updating the spec files
            if (UPDATE_SPEC) {
                var buffer = new GrowableByteBuffer(1024 * 8);
                var serializer = new BufferSerializer(buffer);
                expectedObject.serializeWithId(serializer);
                buffer.flip();

                // Write buffer length in little endian
                var lengthBuffer = ByteBuffer.allocate(4);
                lengthBuffer.order(ByteOrder.LITTLE_ENDIAN);
                lengthBuffer.putInt(buffer.limit());
                out.write(lengthBuffer.array());

                // Write buffer data
                var data = new byte[buffer.limit()];
                buffer.get(data);
                out.write(data);
                out.flush();
                return this;
            }

            int length = readLittleEndianInt(in);
            byte[] originalData = new byte[length];
            in.readFully(originalData);
            Identifiable deserializedObject = Identifiable.create(new BufferSerializer(originalData));

            if (!deserializedObject.equals(expectedObject)) {
                fail(String.format("Serialized object in file '%s' does not equal expected values.\n" +
                                "==================================================\n" +
                                "Expected:\n" +
                                "==================================================\n" +
                                "%s\n" +
                                "==================================================\n" +
                                "Actual:\n" +
                                "==================================================\n" +
                                "%s\n" +
                                "==================================================\n",
                        fileName, dumpObject(expectedObject), dumpObject(deserializedObject)));
            }
            GrowableByteBuffer buffer = new GrowableByteBuffer(1024 * 8);
            BufferSerializer serializer = new BufferSerializer(buffer);
            deserializedObject.serializeWithId(serializer);
            buffer.flip();

            byte[] newData = new byte[buffer.limit()];
            buffer.get(newData);
            if (!Arrays.equals(newData, originalData)) {
                fail(String.format("Serialized object data does not match the original serialized data from file.\n" +
                                "==================================================\n" +
                                "Original:\n" +
                                "==================================================\n" +
                                "%s\n" +
                                "==================================================\n" +
                                "Serialized:\n" +
                                "==================================================\n" +
                                "%s\n" +
                                "==================================================\n",
                        toHexString(originalData), toHexString(newData)));
            }
            return this;
        }
Tests serialization compatibility across Java and C++. The comparison is performed by comparing serialized Java
object graphs with the content of specific binary files. C++ unit tests serializes
identical data structures into these files.
Note: This test relies heavily on proper implementation of {@link Object#equals(Object)}!
searchlib/src/test/java/com/yahoo/searchlib/aggregation/GroupingSerializationTest.java