mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Removed writer's count of bytes written and renamed a method.
This commit is contained in:
@@ -13,7 +13,7 @@ public class AuthorId extends UniqueId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.AUTHOR_ID);
|
w.writeUserDefinedId(Types.AUTHOR_ID);
|
||||||
w.writeBytes(id);
|
w.writeBytes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class BatchId extends UniqueId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.BATCH_ID);
|
w.writeUserDefinedId(Types.BATCH_ID);
|
||||||
w.writeBytes(id);
|
w.writeBytes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class GroupId extends UniqueId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.GROUP_ID);
|
w.writeUserDefinedId(Types.GROUP_ID);
|
||||||
w.writeBytes(id);
|
w.writeBytes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class MessageId extends UniqueId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.MESSAGE_ID);
|
w.writeUserDefinedId(Types.MESSAGE_ID);
|
||||||
w.writeBytes(id);
|
w.writeBytes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface Writer {
|
public interface Writer {
|
||||||
|
|
||||||
long getBytesWritten();
|
|
||||||
|
|
||||||
void writeBoolean(boolean b) throws IOException;
|
void writeBoolean(boolean b) throws IOException;
|
||||||
|
|
||||||
void writeUint7(byte b) throws IOException;
|
void writeUint7(byte b) throws IOException;
|
||||||
@@ -33,5 +31,5 @@ public interface Writer {
|
|||||||
|
|
||||||
void writeNull() throws IOException;
|
void writeNull() throws IOException;
|
||||||
|
|
||||||
void writeUserDefinedTag(int tag) throws IOException;
|
void writeUserDefinedId(int tag) throws IOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class AuthorImpl implements Author {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.AUTHOR);
|
w.writeUserDefinedId(Types.AUTHOR);
|
||||||
w.writeString(name);
|
w.writeString(name);
|
||||||
w.writeBytes(publicKey);
|
w.writeBytes(publicKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class GroupImpl implements Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.GROUP);
|
w.writeUserDefinedId(Types.GROUP);
|
||||||
w.writeString(name);
|
w.writeString(name);
|
||||||
if(publicKey == null) w.writeNull();
|
if(publicKey == null) w.writeNull();
|
||||||
else w.writeBytes(publicKey);
|
else w.writeBytes(publicKey);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class MessageEncoderImpl implements MessageEncoder {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
// Write the message
|
// Write the message
|
||||||
w.writeUserDefinedTag(Types.MESSAGE);
|
w.writeUserDefinedId(Types.MESSAGE);
|
||||||
if(parent == null) w.writeNull();
|
if(parent == null) w.writeNull();
|
||||||
else parent.writeTo(w);
|
else parent.writeTo(w);
|
||||||
if(group == null) w.writeNull();
|
if(group == null) w.writeNull();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class AckWriterImpl implements AckWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void start() throws IOException {
|
private void start() throws IOException {
|
||||||
w.writeUserDefinedTag(Types.ACK);
|
w.writeUserDefinedId(Types.ACK);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
capacity -= headerLength;
|
capacity -= headerLength;
|
||||||
started = true;
|
started = true;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class BatchWriterImpl implements BatchWriter {
|
|||||||
|
|
||||||
private void start() throws IOException {
|
private void start() throws IOException {
|
||||||
messageDigest.reset();
|
messageDigest.reset();
|
||||||
w.writeUserDefinedTag(Types.BATCH);
|
w.writeUserDefinedId(Types.BATCH);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
capacity -= headerLength;
|
capacity -= headerLength;
|
||||||
started = true;
|
started = true;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class OfferWriterImpl implements OfferWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void start() throws IOException {
|
private void start() throws IOException {
|
||||||
w.writeUserDefinedTag(Types.OFFER);
|
w.writeUserDefinedId(Types.OFFER);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
capacity -= headerLength;
|
capacity -= headerLength;
|
||||||
started = true;
|
started = true;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class RequestWriterImpl implements RequestWriter {
|
|||||||
|
|
||||||
public void writeRequest(BitSet b, int length)
|
public void writeRequest(BitSet b, int length)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
w.writeUserDefinedTag(Types.REQUEST);
|
w.writeUserDefinedId(Types.REQUEST);
|
||||||
// If the number of bits isn't a multiple of 8, round up to a byte
|
// If the number of bits isn't a multiple of 8, round up to a byte
|
||||||
int bytes = length % 8 == 0 ? length / 8 : length / 8 + 1;
|
int bytes = length % 8 == 0 ? length / 8 : length / 8 + 1;
|
||||||
byte[] bitmap = new byte[bytes];
|
byte[] bitmap = new byte[bytes];
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class SubscriptionWriterImpl implements SubscriptionWriter {
|
|||||||
|
|
||||||
public void writeSubscriptions(Map<Group, Long> subs, long timestamp)
|
public void writeSubscriptions(Map<Group, Long> subs, long timestamp)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
w.writeUserDefinedTag(Types.SUBSCRIPTION_UPDATE);
|
w.writeUserDefinedId(Types.SUBSCRIPTION_UPDATE);
|
||||||
w.writeMap(subs);
|
w.writeMap(subs);
|
||||||
w.writeInt64(timestamp);
|
w.writeInt64(timestamp);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ class TransportWriterImpl implements TransportWriter {
|
|||||||
|
|
||||||
public void writeTransports(Map<String, Map<String, String>> transports,
|
public void writeTransports(Map<String, Map<String, String>> transports,
|
||||||
long timestamp) throws IOException {
|
long timestamp) throws IOException {
|
||||||
w.writeUserDefinedTag(Types.TRANSPORT_UPDATE);
|
w.writeUserDefinedId(Types.TRANSPORT_UPDATE);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
for(Entry<String, Map<String, String>> e : transports.entrySet()) {
|
for(Entry<String, Map<String, String>> e : transports.entrySet()) {
|
||||||
w.writeUserDefinedTag(Types.TRANSPORT_PROPERTIES);
|
w.writeUserDefinedId(Types.TRANSPORT_PROPERTIES);
|
||||||
w.writeString(e.getKey());
|
w.writeString(e.getKey());
|
||||||
w.writeMap(e.getValue());
|
w.writeMap(e.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,45 +14,35 @@ import net.sf.briar.api.serial.Writer;
|
|||||||
class WriterImpl implements Writer {
|
class WriterImpl implements Writer {
|
||||||
|
|
||||||
private final OutputStream out;
|
private final OutputStream out;
|
||||||
private long bytesWritten = 0L;
|
|
||||||
|
|
||||||
WriterImpl(OutputStream out) {
|
WriterImpl(OutputStream out) {
|
||||||
this.out = out;
|
this.out = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getBytesWritten() {
|
|
||||||
return bytesWritten;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeBoolean(boolean b) throws IOException {
|
public void writeBoolean(boolean b) throws IOException {
|
||||||
if(b) out.write(Tag.TRUE);
|
if(b) out.write(Tag.TRUE);
|
||||||
else out.write(Tag.FALSE);
|
else out.write(Tag.FALSE);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeUint7(byte b) throws IOException {
|
public void writeUint7(byte b) throws IOException {
|
||||||
if(b < 0) throw new IllegalArgumentException();
|
if(b < 0) throw new IllegalArgumentException();
|
||||||
out.write(b);
|
out.write(b);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeInt8(byte b) throws IOException {
|
public void writeInt8(byte b) throws IOException {
|
||||||
out.write(Tag.INT8);
|
out.write(Tag.INT8);
|
||||||
out.write(b);
|
out.write(b);
|
||||||
bytesWritten += 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeInt16(short s) throws IOException {
|
public void writeInt16(short s) throws IOException {
|
||||||
out.write(Tag.INT16);
|
out.write(Tag.INT16);
|
||||||
out.write((byte) (s >> 8));
|
out.write((byte) (s >> 8));
|
||||||
out.write((byte) ((s << 8) >> 8));
|
out.write((byte) ((s << 8) >> 8));
|
||||||
bytesWritten += 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeInt32(int i) throws IOException {
|
public void writeInt32(int i) throws IOException {
|
||||||
out.write(Tag.INT32);
|
out.write(Tag.INT32);
|
||||||
writeInt32Bits(i);
|
writeInt32Bits(i);
|
||||||
bytesWritten += 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeInt32Bits(int i) throws IOException {
|
private void writeInt32Bits(int i) throws IOException {
|
||||||
@@ -65,7 +55,6 @@ class WriterImpl implements Writer {
|
|||||||
public void writeInt64(long l) throws IOException {
|
public void writeInt64(long l) throws IOException {
|
||||||
out.write(Tag.INT64);
|
out.write(Tag.INT64);
|
||||||
writeInt64Bits(l);
|
writeInt64Bits(l);
|
||||||
bytesWritten += 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeInt64Bits(long l) throws IOException {
|
private void writeInt64Bits(long l) throws IOException {
|
||||||
@@ -94,13 +83,11 @@ class WriterImpl implements Writer {
|
|||||||
public void writeFloat32(float f) throws IOException {
|
public void writeFloat32(float f) throws IOException {
|
||||||
out.write(Tag.FLOAT32);
|
out.write(Tag.FLOAT32);
|
||||||
writeInt32Bits(Float.floatToRawIntBits(f));
|
writeInt32Bits(Float.floatToRawIntBits(f));
|
||||||
bytesWritten += 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeFloat64(double d) throws IOException {
|
public void writeFloat64(double d) throws IOException {
|
||||||
out.write(Tag.FLOAT64);
|
out.write(Tag.FLOAT64);
|
||||||
writeInt64Bits(Double.doubleToRawLongBits(d));
|
writeInt64Bits(Double.doubleToRawLongBits(d));
|
||||||
bytesWritten += 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeString(String s) throws IOException {
|
public void writeString(String s) throws IOException {
|
||||||
@@ -111,7 +98,6 @@ class WriterImpl implements Writer {
|
|||||||
writeLength(b.length);
|
writeLength(b.length);
|
||||||
}
|
}
|
||||||
out.write(b);
|
out.write(b);
|
||||||
bytesWritten += b.length + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeLength(int i) throws IOException {
|
private void writeLength(int i) throws IOException {
|
||||||
@@ -129,7 +115,6 @@ class WriterImpl implements Writer {
|
|||||||
writeLength(b.length);
|
writeLength(b.length);
|
||||||
}
|
}
|
||||||
out.write(b);
|
out.write(b);
|
||||||
bytesWritten += b.length + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeList(Collection<?> c) throws IOException {
|
public void writeList(Collection<?> c) throws IOException {
|
||||||
@@ -140,7 +125,6 @@ class WriterImpl implements Writer {
|
|||||||
writeLength(length);
|
writeLength(length);
|
||||||
}
|
}
|
||||||
for(Object o : c) writeObject(o);
|
for(Object o : c) writeObject(o);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeObject(Object o) throws IOException {
|
private void writeObject(Object o) throws IOException {
|
||||||
@@ -162,12 +146,10 @@ class WriterImpl implements Writer {
|
|||||||
|
|
||||||
public void writeListStart() throws IOException {
|
public void writeListStart() throws IOException {
|
||||||
out.write(Tag.LIST_START);
|
out.write(Tag.LIST_START);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeListEnd() throws IOException {
|
public void writeListEnd() throws IOException {
|
||||||
out.write(Tag.END);
|
out.write(Tag.END);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeMap(Map<?, ?> m) throws IOException {
|
public void writeMap(Map<?, ?> m) throws IOException {
|
||||||
@@ -181,33 +163,27 @@ class WriterImpl implements Writer {
|
|||||||
writeObject(e.getKey());
|
writeObject(e.getKey());
|
||||||
writeObject(e.getValue());
|
writeObject(e.getValue());
|
||||||
}
|
}
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeMapStart() throws IOException {
|
public void writeMapStart() throws IOException {
|
||||||
out.write(Tag.MAP_START);
|
out.write(Tag.MAP_START);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeMapEnd() throws IOException {
|
public void writeMapEnd() throws IOException {
|
||||||
out.write(Tag.END);
|
out.write(Tag.END);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNull() throws IOException {
|
public void writeNull() throws IOException {
|
||||||
out.write(Tag.NULL);
|
out.write(Tag.NULL);
|
||||||
bytesWritten++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeUserDefinedTag(int tag) throws IOException {
|
public void writeUserDefinedId(int id) throws IOException {
|
||||||
if(tag < 0 || tag > 255) throw new IllegalArgumentException();
|
if(id < 0 || id > 255) throw new IllegalArgumentException();
|
||||||
if(tag < 32) {
|
if(id < 32) {
|
||||||
out.write((byte) (Tag.SHORT_USER | tag));
|
out.write((byte) (Tag.SHORT_USER | id));
|
||||||
bytesWritten++;
|
|
||||||
} else {
|
} else {
|
||||||
out.write(Tag.USER);
|
out.write(Tag.USER);
|
||||||
out.write((byte) tag);
|
out.write((byte) id);
|
||||||
bytesWritten += 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,18 +100,18 @@ public class AckReaderTest extends TestCase {
|
|||||||
private byte[] createAck(boolean tooBig) throws Exception {
|
private byte[] createAck(boolean tooBig) throws Exception {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
w.writeUserDefinedTag(Types.ACK);
|
w.writeUserDefinedId(Types.ACK);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
byte[] b = new byte[UniqueId.LENGTH];
|
byte[] b = new byte[UniqueId.LENGTH];
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
while(out.size() + BatchId.LENGTH + 3
|
while(out.size() + BatchId.LENGTH + 3
|
||||||
< ProtocolConstants.MAX_PACKET_LENGTH) {
|
< ProtocolConstants.MAX_PACKET_LENGTH) {
|
||||||
w.writeUserDefinedTag(Types.BATCH_ID);
|
w.writeUserDefinedId(Types.BATCH_ID);
|
||||||
random.nextBytes(b);
|
random.nextBytes(b);
|
||||||
w.writeBytes(b);
|
w.writeBytes(b);
|
||||||
}
|
}
|
||||||
if(tooBig) {
|
if(tooBig) {
|
||||||
w.writeUserDefinedTag(Types.BATCH_ID);
|
w.writeUserDefinedId(Types.BATCH_ID);
|
||||||
random.nextBytes(b);
|
random.nextBytes(b);
|
||||||
w.writeBytes(b);
|
w.writeBytes(b);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ public class AckReaderTest extends TestCase {
|
|||||||
private byte[] createEmptyAck() throws Exception {
|
private byte[] createEmptyAck() throws Exception {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
w.writeUserDefinedTag(Types.ACK);
|
w.writeUserDefinedId(Types.ACK);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
w.writeListEnd();
|
w.writeListEnd();
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
|
|||||||
@@ -143,10 +143,10 @@ public class BatchReaderTest extends TestCase {
|
|||||||
private byte[] createBatch(int size) throws Exception {
|
private byte[] createBatch(int size) throws Exception {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream(size);
|
ByteArrayOutputStream out = new ByteArrayOutputStream(size);
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
w.writeUserDefinedTag(Types.BATCH);
|
w.writeUserDefinedId(Types.BATCH);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
// We're using a fake message reader, so it's OK to use a fake message
|
// We're using a fake message reader, so it's OK to use a fake message
|
||||||
w.writeUserDefinedTag(Types.MESSAGE);
|
w.writeUserDefinedId(Types.MESSAGE);
|
||||||
w.writeBytes(new byte[size - 10]);
|
w.writeBytes(new byte[size - 10]);
|
||||||
w.writeListEnd();
|
w.writeListEnd();
|
||||||
byte[] b = out.toByteArray();
|
byte[] b = out.toByteArray();
|
||||||
@@ -157,7 +157,7 @@ public class BatchReaderTest extends TestCase {
|
|||||||
private byte[] createEmptyBatch() throws Exception {
|
private byte[] createEmptyBatch() throws Exception {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
w.writeUserDefinedTag(Types.BATCH);
|
w.writeUserDefinedId(Types.BATCH);
|
||||||
w.writeListStart();
|
w.writeListStart();
|
||||||
w.writeListEnd();
|
w.writeListEnd();
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class RequestReaderTest extends TestCase {
|
|||||||
private byte[] createRequest(boolean tooBig) throws Exception {
|
private byte[] createRequest(boolean tooBig) throws Exception {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
w.writeUserDefinedTag(Types.REQUEST);
|
w.writeUserDefinedId(Types.REQUEST);
|
||||||
// Allow one byte for the REQUEST tag, one byte for the BYTES tag,
|
// Allow one byte for the REQUEST tag, one byte for the BYTES tag,
|
||||||
// and five bytes for the length as an int32
|
// and five bytes for the length as an int32
|
||||||
int size = ProtocolConstants.MAX_PACKET_LENGTH - 7;
|
int size = ProtocolConstants.MAX_PACKET_LENGTH - 7;
|
||||||
@@ -128,7 +128,7 @@ public class RequestReaderTest extends TestCase {
|
|||||||
private byte[] createRequest(byte[] bitmap) throws Exception {
|
private byte[] createRequest(byte[] bitmap) throws Exception {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Writer w = writerFactory.createWriter(out);
|
Writer w = writerFactory.createWriter(out);
|
||||||
w.writeUserDefinedTag(Types.REQUEST);
|
w.writeUserDefinedId(Types.REQUEST);
|
||||||
w.writeBytes(bitmap);
|
w.writeBytes(bitmap);
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,8 +269,8 @@ public class WriterImplTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteShortUserDefinedTag() throws IOException {
|
public void testWriteShortUserDefinedTag() throws IOException {
|
||||||
w.writeUserDefinedTag(0);
|
w.writeUserDefinedId(0);
|
||||||
w.writeUserDefinedTag(31);
|
w.writeUserDefinedId(31);
|
||||||
// SHORT_USER tag (3 bits), 0 (5 bits), SHORT_USER tag (3 bits),
|
// SHORT_USER tag (3 bits), 0 (5 bits), SHORT_USER tag (3 bits),
|
||||||
// 31 (5 bits)
|
// 31 (5 bits)
|
||||||
checkContents("C0" + "DF");
|
checkContents("C0" + "DF");
|
||||||
@@ -278,8 +278,8 @@ public class WriterImplTest extends TestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWriteUserDefinedTag() throws IOException {
|
public void testWriteUserDefinedTag() throws IOException {
|
||||||
w.writeUserDefinedTag(32);
|
w.writeUserDefinedId(32);
|
||||||
w.writeUserDefinedTag(255);
|
w.writeUserDefinedId(255);
|
||||||
// USER tag, 32 as uint8, USER tag, 255 as uint8
|
// USER tag, 32 as uint8, USER tag, 255 as uint8
|
||||||
checkContents("EF" + "20" + "EF" + "FF");
|
checkContents("EF" + "20" + "EF" + "FF");
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ public class WriterImplTest extends TestCase {
|
|||||||
public void testWriteCollectionOfWritables() throws IOException {
|
public void testWriteCollectionOfWritables() throws IOException {
|
||||||
Writable writable = new Writable() {
|
Writable writable = new Writable() {
|
||||||
public void writeTo(Writer w) throws IOException {
|
public void writeTo(Writer w) throws IOException {
|
||||||
w.writeUserDefinedTag(0);
|
w.writeUserDefinedId(0);
|
||||||
w.writeString("foo");
|
w.writeString("foo");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user