### Question:
PGProto { public int readInt32() { int value = getInt32(offset); offset += 4; return value; } PGProto(byte[] packet, int offset);  PGProto(byte[] packet); boolean hasRemaining(); byte[] readBytes(int size); byte readByte(); byte getByte(int offset); int readInt8(); int readInt16(); int getInt16(int offset); int readInt32(); int getInt32(int offset); String readNullStr(); String readFixedStr(int length); String readFixedStr(int offset, int length); static byte[] buildInt16BE(final int value); static byte[] buildInt32BE(final int value); static byte[] buildNullStr(String str);  }### Answer:
@Test public void testReadMaxUnsignedInt32() throws Exception { byte[] maxUnsignedInt = new byte[] {unsignedMaxByte, unsignedMaxByte, unsignedMaxByte, unsignedMaxByte}; PGProto proto = new PGProto(maxUnsignedInt, 0); int actualMaxUnsignedInt = proto.readInt32(); int expectedInt = -1; assertEquals(actualMaxUnsignedInt, expectedInt); }
@Test public void testReadMinUnsignedInt32() { byte[] minUnsginedInt = new byte[] {unsignedByte0, unsignedByte0, unsignedByte0, unsignedByte0}; PGProto proto = new PGProto(minUnsginedInt, 0); int actualMinUnsignedInt = proto.readInt32(); int expectedInt = 0; assertEquals(actualMinUnsignedInt, expectedInt); }
@Test public void testReadPostiveInt32() { byte[] postiveInt1 = new byte[] {unsignedByte0, unsignedByte0, unsignedByte0, unsignedByte1}; PGProto proto = new PGProto(postiveInt1, 0); int actualInt = proto.readInt32(); int expectedInt = 1; assertEquals(actualInt, expectedInt); }
@Test public void testReadNegativeInt32() { byte[] negativeInt1 = new byte[] {unsignedMaxByte, unsignedMaxByte, unsignedMaxByte, unsignedByte2}; PGProto proto = new PGProto(negativeInt1, 0); int actualInt = proto.readInt32(); int expectedInt = -254; assertEquals(actualInt, expectedInt); }