use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testUnsignedShort.
public void testUnsignedShort() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(20);
out.writeShort(-22);
out.writeShort(22);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
short num = in.readShort();
assert num == -22;
num = in.readShort();
assert num == 22;
in.position(0);
int val = in.readUnsignedShort();
assert val == 65514;
val = in.readUnsignedShort();
assert val == 22;
}
use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testDouble.
public void testDouble() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(1024);
double[] numbers = { -322649.25, 100.7531, 0.0, 1.5, 2.75, 3.1425, 322649, 322649.75 };
for (double i : numbers) out.writeDouble(i);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
for (double i : numbers) {
double num = in.readDouble();
assert num == i;
}
}
use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testExpanding3.
public void testExpanding3() {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(1024);
out.writeInt(1);
assert out.position() == 4;
byte[] buf = new byte[1024];
out.write(buf);
System.out.println("out=" + out);
assert out.position() == 1028;
buf = new byte[512];
out.write(buf);
System.out.println("out = " + out);
assert out.position() == 1028 + 512;
}
use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testInt.
public void testInt() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(1024);
int[] numbers = { Integer.MIN_VALUE, -322649, -500, 0, 1, 100, 322649, Integer.MAX_VALUE };
for (int i : numbers) out.writeInt(i);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
for (int i : numbers) {
int num = in.readInt();
assert num == i;
}
}
use of org.jgroups.util.ByteArrayDataOutputStream in project JGroups by belaban.
the class ByteArrayDataInputOutputStreamTest method testFloat.
public void testFloat() throws IOException {
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream(1024);
float[] numbers = { -322649.25f, 100.7531f, 0f, 1f, 2.75f, 3.1425f, 322649f, 322649.75f };
for (float i : numbers) out.writeFloat(i);
ByteArrayDataInputStream in = new ByteArrayDataInputStream(out.buffer());
for (float i : numbers) {
float num = in.readFloat();
assert num == i;
}
}
Aggregations