Skip to content

Commit

Permalink
Test case for ByteBufCodedOutputStream.writeDouble (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
jai1 authored Mar 1, 2017
1 parent c5200ff commit f6d2219
Showing 1 changed file with 22 additions and 0 deletions.
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);
}
}

0 comments on commit f6d2219

Please sign in to comment.