summaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/common/util/TestBitstream04.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-12-03 20:30:46 +0100
committerSven Gothel <[email protected]>2014-12-03 20:30:46 +0100
commit9e13e8c78ed69bb7afcd49abe8bf69340dc06223 (patch)
tree956c8bb0ab085e7325aa18400681be7612224dae /src/junit/com/jogamp/common/util/TestBitstream04.java
parentca4f075aeed16331f0b806ea564ca3d492039336 (diff)
Bug 1106 - Bitstream: Simplify 'msbFirst' case for bulk operations / Add setting of stream position (optional)
- Add setting position entry, optionally supported, e.g. ByteBufferStream and ByteArrayStream - Remove 'msbFirst' parameter on all 'bulk' read/write operations. These methods use LSB-first always, allowing proper stream access of data w/ different bit-sizes. Data is now read/write as little-endian and swapped accordingly. Optimizations are adopted for LSB-first operations. This change removes API confusion/bugs: - removes one decision (parameter) - removes the data reversion case - removes bugs w/ different bit-sizes
Diffstat (limited to 'src/junit/com/jogamp/common/util/TestBitstream04.java')
-rw-r--r--src/junit/com/jogamp/common/util/TestBitstream04.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/junit/com/jogamp/common/util/TestBitstream04.java b/src/junit/com/jogamp/common/util/TestBitstream04.java
index 277510e..47be38d 100644
--- a/src/junit/com/jogamp/common/util/TestBitstream04.java
+++ b/src/junit/com/jogamp/common/util/TestBitstream04.java
@@ -47,8 +47,8 @@ import org.junit.runners.MethodSorters;
* Test {@link Bitstream} w/ int32 read/write access w/ semantics
* as well as with aligned and unaligned access.
* <ul>
- * <li>{@link Bitstream#readUInt32(boolean, boolean)}</li>
- * <li>{@link Bitstream#writeInt32(boolean, boolean, int)}</li>
+ * <li>{@link Bitstream#readUInt32(boolean)}</li>
+ * <li>{@link Bitstream#writeInt32(boolean, int)}</li>
* </ul>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -82,11 +82,12 @@ public class TestBitstream04 extends SingletonJunitCase {
System.err.println("XXX Test01Int32BitsAligned: "+val32+", "+val32_hs);
bb.putInt(0, val32);
+ dumpData("TestData.1: ", bb, 0, 4);
final Bitstream.ByteBufferStream bbs = new Bitstream.ByteBufferStream(bb);
final Bitstream<ByteBuffer> bs = new Bitstream<ByteBuffer>(bbs, false /* outputMode */);
{
- final long uint32_l = bs.readUInt32(true /* msbFirst */, bigEndian);
+ final long uint32_l = bs.readUInt32(bigEndian);
final int int32_l = (int)uint32_l;
final String uint32_l_hs = toHexString(uint32_l);
final int uint32_i = Bitstream.uint32LongToInt(uint32_l);
@@ -99,10 +100,11 @@ public class TestBitstream04 extends SingletonJunitCase {
// Test with written bitstream value
bs.setStream(bs.getSubStream(), true /* outputMode */);
- bs.writeInt32(true /* msbFirst */, bigEndian, val32);
+ bs.writeInt32(bigEndian, val32);
bs.setStream(bs.getSubStream(), false /* outputMode */); // switch to input-mode, implies flush()
+ dumpData("TestData.2: ", bb, 0, 4);
{
- final long uint32_l = bs.readUInt32(true /* msbFirst */, bigEndian);
+ final long uint32_l = bs.readUInt32(bigEndian);
final int int32_l = (int)uint32_l;
final String uint32_l_hs = toHexString(uint32_l);
final int uint32_i = Bitstream.uint32LongToInt(uint32_l);
@@ -154,12 +156,12 @@ public class TestBitstream04 extends SingletonJunitCase {
// Test with written bitstream value
final Bitstream.ByteBufferStream bbs = new Bitstream.ByteBufferStream(bb);
final Bitstream<ByteBuffer> bs = new Bitstream<ByteBuffer>(bbs, true /* outputMode */);
- bs.writeBits31(true /* msbFirst */, preBits, 0);
- bs.writeInt32(true /* msbFirst */, bigEndian, val32);
+ bs.writeBits31(preBits, 0);
+ bs.writeInt32(bigEndian, val32);
bs.setStream(bs.getSubStream(), false /* outputMode */); // switch to input-mode, implies flush()
- final int rPre = bs.readBits31(true /* msbFirst */, preBits);
- final long uint32_l = bs.readUInt32(true /* msbFirst */, bigEndian);
+ final int rPre = bs.readBits31(preBits);
+ final long uint32_l = bs.readUInt32(bigEndian);
final int int32_l = (int)uint32_l;
final String uint32_l_hs = toHexString(uint32_l);
final int uint32_i = Bitstream.uint32LongToInt(uint32_l);