get a nontrivial test to pass

This commit is contained in:
David Renshaw 2014-09-26 11:54:04 -04:00
parent 0ea0d1f909
commit ae24deaba9
2 changed files with 16 additions and 10 deletions

View file

@ -39,49 +39,49 @@ public final class PackedOutputStream implements WritableByteChannel {
curByte = inBuf.get(inPtr);
byte bit0 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit0);
out.position(out.position() + bit0 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit1 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit1);
out.position(out.position() + bit1 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit2 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit2);
out.position(out.position() + bit2 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit3 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit3);
out.position(out.position() + bit3 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit4 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit4);
out.position(out.position() + bit4 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit5 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit5);
out.position(out.position() + bit5 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit6 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit6);
out.position(out.position() + bit6 - 1);
inPtr += 1;
curByte = inBuf.get(inPtr);
byte bit7 = (curByte != 0) ? (byte)1 : (byte)0;
out.put(curByte);
out.position(out.position() - bit7);
out.position(out.position() + bit7 - 1);
inPtr += 1;
byte tag = (byte)((bit0 << 0) | (bit1 << 1) | (bit2 << 2) | (bit3 << 3) |
@ -121,8 +121,14 @@ public final class PackedOutputStream implements WritableByteChannel {
// TODO
}
}
if (out == slowBuffer) {
out.limit(out.position());
out.rewind();
this.inner.write(out);
}
return length;
}

View file

@ -21,6 +21,6 @@ class SerializePackedSuite extends FunSuite {
test("SimplePacking") {
expectPacksTo(Array(), Array());
//expectPacksTo(Array(0,0,12,0,0,34,0,0), Array(0x24,12,34));
expectPacksTo(Array(0,0,12,0,0,34,0,0), Array(0x24,12,34));
}
}