diff --git a/src/test/java/net/openhft/chronicle/wire/issue/Issue751Test.java b/src/test/java/net/openhft/chronicle/wire/issue/Issue751Test.java new file mode 100644 index 0000000000..6a5c63ca58 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/wire/issue/Issue751Test.java @@ -0,0 +1,49 @@ +package net.openhft.chronicle.wire.issue; + +import net.openhft.chronicle.bytes.Bytes; +import net.openhft.chronicle.wire.*; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; + +public class Issue751Test extends WireTestCommon { + + public static class One extends SelfDescribingMarshallable { + Comparable text; + + public One(Comparable text) { + this.text = text; + } + } + + public static class Two implements Comparable, Marshallable { + Comparable text; + + public Two(Comparable text) { + this.text = text; + } + + @Override + public int compareTo(@NotNull Issue751Test.Two o) { + return text.hashCode() - o.text.hashCode(); + } + } + + public static class Three extends SelfDescribingMarshallable { + private One one; + private Two two; + + public Three(One one, Two two) { + this.one = one; + this.two = two; + } + } + + @Test + public void comparableField() { + Wire wire = new YamlWire(Bytes.allocateElasticOnHeap()); + wire.write("first").object(new Three( + new One("hello"), new Two(42))); + + System.err.println(wire.read("first").object()); + } +} \ No newline at end of file