### Question:
BCHBechAddress { public static BechAddressParams bchBechDecode(String bech) throws Exception { byte[] buffer = bech.getBytes(); for (byte b : buffer) { if (b < 0x21 || b > 0x7e) { throw new Exception("bech32 characters out of range"); } } if (!bech.equals(bech.toLowerCase(Locale.ROOT)) && !bech.equals(bech.toUpperCase(Locale.ROOT))) { throw new Exception("BCH bech32 cannot mix upper and lower case"); } bech = bech.toLowerCase(); int position = bech.lastIndexOf(":"); if (position < 1) { throw new Exception("BCH bech32 missing separator"); } else if (position + 7 > bech.length()) { throw new Exception("BCH bech32 separator misplaced"); } else if (bech.length() < 8) { throw new Exception("BCH bech32 input too short"); } else if (bech.length() > 90) { throw new Exception("BCH bech32 input too long"); } String s = bech.substring(position + 1); for (int i = 0; i < s.length(); i++) { if (CHARSET.indexOf(s.charAt(i)) == -1) { throw new Exception("BCH bech32 characters out of range"); } } byte[] humanReadablePart = bech.substring(0, position).getBytes(); byte[] data = new byte[bech.length() - position - 1]; for (int j = 0, i = position + 1; i < bech.length(); i++, j++) { data[j] = (byte) CHARSET.indexOf(bech.charAt(i)); } if (!verifyChecksum(humanReadablePart, data)) { throw new Exception("invalid BCH bech32 checksum"); } byte[] payloadData = fromBase5Array(Arrays.copyOfRange(data, 0, data.length - 8)); byte[] hash = Arrays.copyOfRange(payloadData, 1, payloadData.length); String type = getType(payloadData[0]); return new BechAddressParams(type, hash, new String(humanReadablePart)); }  static BechAddressParams bchBechDecode(String bech);  }### Answer:
@Test public void P2PKHAddressTest() throws Exception { Assert.assertEquals(Address.fromStandardBytes(BCHBechAddress.bchBechDecode("bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a").getHash(), NetworkParameters.productionNetwork).toString(), "1BpEi6DfDAUFd7GtittLSdBeYJvcoaVggu"); }
@Test public void P2SHAddressTest() throws Exception { Assert.assertEquals(Address.fromP2SHBytes(BCHBechAddress.bchBechDecode("bitcoincash:pqq3728yw0y47sqn6l2na30mcw6zm78dzq5ucqzc37").getHash(), NetworkParameters.productionNetwork).toString(), "31nwvkZwyPdgzjBJZXfDmSWsC4ZLKpYyUw"); }
@Test public void legacyAddressConstructorTest() throws Exception { Assert.assertEquals(BCHBechAddress.bchBechDecode("bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a") .constructLegacyAddress(NetworkParameters.productionNetwork).toString(), "1BpEi6DfDAUFd7GtittLSdBeYJvcoaVggu"); Assert.assertEquals(BCHBechAddress.bchBechDecode("bitcoincash:pqq3728yw0y47sqn6l2na30mcw6zm78dzq5ucqzc37") .constructLegacyAddress(NetworkParameters.productionNetwork).toString(), "31nwvkZwyPdgzjBJZXfDmSWsC4ZLKpYyUw"); }