1.0 preparations
This commit is contained in:
parent
55717c6e71
commit
8fa82633d4
34 changed files with 742 additions and 462 deletions
|
|
@ -9,19 +9,19 @@ import org.junit.Test;
|
|||
public class BitCoderContextTest
|
||||
{
|
||||
@Test
|
||||
public void distanceEncodeDecodeTest()
|
||||
public void varBitsEncodeDecodeTest()
|
||||
{
|
||||
byte[] ab = new byte[4000];
|
||||
BitCoderContext ctx = new BitCoderContext( ab );
|
||||
for( int i=0; i<1000; i++ )
|
||||
{
|
||||
ctx.encodeDistance( i );
|
||||
ctx.encodeVarBits( i );
|
||||
}
|
||||
ctx = new BitCoderContext( ab );
|
||||
|
||||
for( int i=0; i<1000; i++ )
|
||||
{
|
||||
int value = ctx.decodeDistance();
|
||||
int value = ctx.decodeVarBits();
|
||||
Assert.assertTrue( "distance value mismatch", value == i );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
brouter-util/src/test/java/btools/util/ByteDataIOTest.java
Normal file
28
brouter-util/src/test/java/btools/util/ByteDataIOTest.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package btools.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ByteDataIOTest
|
||||
{
|
||||
@Test
|
||||
public void varLengthEncodeDecodeTest()
|
||||
{
|
||||
byte[] ab = new byte[4000];
|
||||
ByteDataWriter w = new ByteDataWriter( ab );
|
||||
for( int i=0; i<1000; i++ )
|
||||
{
|
||||
w.writeVarLengthUnsigned( i );
|
||||
}
|
||||
ByteDataReader r = new ByteDataReader( ab );
|
||||
|
||||
for( int i=0; i<1000; i++ )
|
||||
{
|
||||
int value = r.readVarLengthUnsigned();
|
||||
Assert.assertTrue( "value mismatch", value == i );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue