diff --git a/core/src/test/java/org/bitcoinj/core/VarIntTest.java b/core/src/test/java/org/bitcoinj/core/VarIntTest.java index 5b59e551..b48b67c2 100644 --- a/core/src/test/java/org/bitcoinj/core/VarIntTest.java +++ b/core/src/test/java/org/bitcoinj/core/VarIntTest.java @@ -18,7 +18,11 @@ package org.bitcoinj.core; import junit.framework.TestCase; +import org.junit.Test; + public class VarIntTest extends TestCase { + + @Test public void testBytes() throws Exception { VarInt a = new VarInt(10); // with widening conversion assertEquals(1, a.getSizeInBytes()); @@ -26,6 +30,7 @@ public class VarIntTest extends TestCase { assertEquals(10, new VarInt(a.encode(), 0).value); } + @Test public void testShorts() throws Exception { VarInt a = new VarInt(64000); // with widening conversion assertEquals(3, a.getSizeInBytes()); @@ -33,6 +38,7 @@ public class VarIntTest extends TestCase { assertEquals(64000, new VarInt(a.encode(), 0).value); } + @Test public void testShortFFFF() throws Exception { VarInt a = new VarInt(0xFFFFL); assertEquals(3, a.getSizeInBytes()); @@ -40,6 +46,7 @@ public class VarIntTest extends TestCase { assertEquals(0xFFFFL, new VarInt(a.encode(), 0).value); } + @Test public void testInts() throws Exception { VarInt a = new VarInt(0xAABBCCDDL); assertEquals(5, a.getSizeInBytes()); @@ -48,6 +55,7 @@ public class VarIntTest extends TestCase { assertEquals(0xAABBCCDDL, 0xFFFFFFFFL & new VarInt(bytes, 0).value); } + @Test public void testIntFFFFFFFF() throws Exception { VarInt a = new VarInt(0xFFFFFFFFL); assertEquals(5, a.getSizeInBytes()); @@ -56,6 +64,7 @@ public class VarIntTest extends TestCase { assertEquals(0xFFFFFFFFL, 0xFFFFFFFFL & new VarInt(bytes, 0).value); } + @Test public void testLong() throws Exception { VarInt a = new VarInt(0xCAFEBABEDEADBEEFL); assertEquals(9, a.getSizeInBytes()); @@ -64,6 +73,7 @@ public class VarIntTest extends TestCase { assertEquals(0xCAFEBABEDEADBEEFL, new VarInt(bytes, 0).value); } + @Test public void testSizeOfNegativeInt() throws Exception { // shouldn't normally be passed, but at least stay consistent (bug regression test) assertEquals(VarInt.sizeOf(-1), new VarInt(-1).encode().length);