if (!u2.equals(union)) {
throw new RuntimeException("serialization fails!");
}
StructWithAUnion swau = new StructWithAUnion(u2);
buf = new TMemoryBuffer(0);
proto = new TBinaryProtocol(buf);
swau.write(proto);
StructWithAUnion swau2 = new StructWithAUnion();
if (swau2.equals(swau)) {
throw new RuntimeException("objects match before they are supposed to!");
}
swau2.read(proto);
if (!swau2.equals(swau)) {
throw new RuntimeException("objects don't match when they are supposed to!");
}
// this should NOT throw an exception.
buf = new TMemoryBuffer(0);