Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import static org.testng.Assert.assertEquals;

import java.io.IOException;

Expand All @@ -26,6 +27,7 @@
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.WireFormat;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class ByteBufCodedInputStreamTest {
Expand Down Expand Up @@ -69,4 +71,24 @@ public void testByteBufCondedInputStreamTest() throws IOException {
}

}

@Test
public void testWritingDouble() throws IOException {
ByteBuf buf = Unpooled.buffer();
buf.clear();
ByteBufCodedOutputStream outputStream = ByteBufCodedOutputStream.get(buf);
outputStream.writeDouble(12, 23d);
outputStream.writeDouble(15, 13.13d);
outputStream.writeDouble(1, -0.003d);

ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(buf);
assertEquals(WireFormat.getTagFieldNumber(inputStream.readTag()), 12);
assertEquals(inputStream.readDouble(), 23d);

assertEquals(WireFormat.getTagFieldNumber(inputStream.readTag()), 15);
assertEquals(inputStream.readDouble(), 13.13d);

assertEquals(WireFormat.getTagFieldNumber(inputStream.readTag()), 1);
assertEquals(inputStream.readDouble(), -0.003d);
}
}