@Override
public void testDouble(double v) throws Exception {
MessagePack msgpack = new JSON();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
if(((Double)v).isInfinite() || ((Double)v).isNaN()) {
try {
packer.writeDouble(v);
fail("JSONPacker should reject infinite and NaN value");
} catch (IOException ex) {
assertTrue(ex instanceof IOException);
}
return;
}
packer.writeDouble(v);
byte[] bytes = out.toByteArray();
Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
double ret = unpacker.readDouble();
assertEquals(v, ret, 10e-10);
}