### Question:
PGProto { public static byte[] buildInt32BE(final int value) { byte[] bytes = new byte[4]; bytes[0] = (byte) (value >>> 24); bytes[1] = (byte) (value >>> 16); bytes[2] = (byte) (value >>> 8); bytes[3] = (byte) value; return bytes; } 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 testBuildMaxUnsignedInt32() { byte[] actalBytes = PGProto.buildInt32BE(-1); byte[] expectedBytes = new byte[] {unsignedMaxByte, unsignedMaxByte, unsignedMaxByte, unsignedMaxByte}; assertTrue(Arrays.equals(actalBytes, expectedBytes)); }
@Test public void testBuildMinUnsignedInt32() { byte[] actalBytes = PGProto.buildInt32BE(0); byte[] expectedBytes = new byte[] {unsignedByte0, unsignedByte0, unsignedByte0, unsignedByte0}; assertTrue(Arrays.equals(actalBytes, expectedBytes)); }
@Test public void testBuildPostiveInt32() { byte[] actalBytes = PGProto.buildInt32BE(1); byte[] expectedBytes = new byte[] {unsignedByte0, unsignedByte0, unsignedByte0, unsignedByte1}; assertTrue(Arrays.equals(actalBytes, expectedBytes)); }
@Test public void testBuildNegativeInt32() { byte[] actalBytes = PGProto.buildInt32BE(-254); byte[] expectedBytes = new byte[] {unsignedMaxByte, unsignedMaxByte, unsignedMaxByte, unsignedByte2}; assertTrue(Arrays.equals(actalBytes, expectedBytes)); }
@Test public void testBuildMaxSignedInt32() { byte[] actalBytes = PGProto.buildInt32BE(Integer.MAX_VALUE); byte[] expectedBytes = new byte[] {(byte) 0b01111111, unsignedMaxByte, unsignedMaxByte, unsignedMaxByte}; assertTrue(Arrays.equals(actalBytes, expectedBytes)); }
@Test public void testBuildMinSignedInt32() { byte[] actalBytes = PGProto.buildInt32BE(Integer.MIN_VALUE); byte[] expectedBytes = new byte[] {unsignedByte128, unsignedByte0, unsignedByte0, unsignedByte0}; assertTrue(Arrays.equals(actalBytes, expectedBytes)); }