### Question:
B2StringUtil { public static int decimalSubstringToInt(String s, int startIndex, int endIndex) { int result = 0; for (int i = startIndex; i < endIndex; i++) { result = result * 10 + decimalCharToInt(s.charAt(i)); } return result; } B2StringUtil(); static String percentEncode(String s); static String percentDecode(String s); static int decimalSubstringToInt(String s, int startIndex, int endIndex); static boolean decimalNumberInRange(String str, int offset, int length,
                                               int minInclusive, int maxInclusive); static String join(String delimiter, Object[] objects); static byte [] getUtf8Bytes(String str); static String toHexString(byte[] b); static String underscoresToCamelCase(String orig, boolean capitalizeFirstLetter); static boolean startsWithIgnoreCase(String all, String possiblePrefix); static final String UTF8; }### Answer:
@Test public void testDecimalSubstringToInt() { assertEquals(0, decimalSubstringToInt("a123456b", 0, 0)); assertEquals(2, decimalSubstringToInt("a123456b", 2, 3)); assertEquals(123456, decimalSubstringToInt("a123456b", 1, 7)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Character a is not a digit"); decimalSubstringToInt("012a345", 2, 4); }