-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for Comparable Marshallable - closes #751
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/test/java/net/openhft/chronicle/wire/issue/Issue751Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Two>, 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()); | ||
} | ||
} |