MySQLPacketPayload implements PacketPayload { public void writeIntLenenc(final long value) { if (value < 0xfb) { byteBuf.writeByte((int) value); return; } if (value < Math.pow(2, 16)) { byteBuf.writeByte(0xfc); byteBuf.writeShortLE((int) value); return; } if (value < Math.pow(2, 24)) { byteBuf.writeByte(0xfd); byteBuf.writeMediumLE((int) value); return; } byteBuf.writeByte(0xfe); byteBuf.writeLongLE(value); }  int readInt1(); void writeInt1(final int value); int readInt2(); void writeInt2(final int value); int readInt3(); void writeInt3(final int value); int readInt4(); void writeInt4(final int value); long readInt6(); void writeInt6(final int value); long readInt8(); void writeInt8(final long value); long readIntLenenc(); void writeIntLenenc(final long value); long readLong(final int length); String readStringLenenc(); byte[] readStringLenencByBytes(); void writeStringLenenc(final String value); void writeBytesLenenc(final byte[] value); String readStringFix(final int length); byte[] readStringFixByBytes(final int length); void writeStringFix(final String value); void writeBytes(final byte[] value); String readStringVar(); void writeStringVar(final String value); String readStringNul(); byte[] readStringNulByBytes(); void writeStringNul(final String value); byte[] readStringEOFByBytes(); String readStringEOF(); void writeStringEOF(final String value); void skipReserved(final int length); void writeReserved(final int length); @Override void close();  }
@Test public void assertWriteIntLenencWithOneByte() { new MySQLPacketPayload(byteBuf).writeIntLenenc(1L); verify(byteBuf).writeByte(1); }
@Test public void assertWriteIntLenencWithTwoBytes() { new MySQLPacketPayload(byteBuf).writeIntLenenc(new Double(Math.pow(2, 16)).longValue() - 1); verify(byteBuf).writeByte(0xfc); verify(byteBuf).writeShortLE(new Double(Math.pow(2, 16)).intValue() - 1); }
@Test public void assertWriteIntLenencWithThreeBytes() { new MySQLPacketPayload(byteBuf).writeIntLenenc(new Double(Math.pow(2, 24)).longValue() - 1); verify(byteBuf).writeByte(0xfd); verify(byteBuf).writeMediumLE(new Double(Math.pow(2, 24)).intValue() - 1); }
@Test public void assertWriteIntLenencWithFourBytes() { new MySQLPacketPayload(byteBuf).writeIntLenenc(new Double(Math.pow(2, 25)).longValue() - 1); verify(byteBuf).writeByte(0xfe); verify(byteBuf).writeLongLE(new Double(Math.pow(2, 25)).intValue() - 1); }