### Question:
NumberHelper { public static long parseLong(final String string, final long defaultValue) { if (StringHelper.isEmpty(string)) { return defaultValue; } final boolean negative = string.charAt(0) == '-'; final int length = string.length(); int index = negative ? 1 : 0; if (index == length) { return defaultValue; } int digit = string.charAt(index++) - '0'; if ( (digit < 0) || (digit > 9) ) { return defaultValue; } long accumulator = -digit; long cap = Long.MIN_VALUE / 10; while (index < length) { digit = string.charAt(index++) - '0'; if ( (digit < 0) || (digit > 9) || (accumulator < cap) ) { return defaultValue; } accumulator *= 10; if (accumulator < Long.MIN_VALUE + digit) { return defaultValue; } accumulator -= digit; } if (negative) { return accumulator; } else if (accumulator == Long.MIN_VALUE) { return defaultValue; } else { return -accumulator; } } private  NumberHelper(); static int boundInteger(int toBound, IntRange range); static int boundInteger(int toBound, int minimum, int maximum); static long boundLong(long toBound, LongRange range); static long boundLong(long toBound, long minimum, long maximum); static int parseInt(final String string, final int defaultValue); static int parseInt(final String string); static int parseInt(final String string, final int defaultValue,
      final int minimum, final int maximum); static long parseLong(final String string, final long defaultValue); static long parseLong(final String string); static long parseLong(final String string, final long defaultValue,
      final long minimum, final long maximum); static boolean isNumber(final String string); static int parseIntPermissive(String numStr, int defaultValue); static float parseFloat(String numStr, float defaultValue); static double parseDouble(String numStr, double defaultValue); static double round(double value, int decimalPlaces); static int getPageStartOffset(int page, int pageSize); static int getPageStartOffset(int page, int pageSize, int maximum); static int getPageEndOffset(int page, int pageSize, int maximum); static int getPageCount(int items, int pageSize); static Double getMedian(List<Integer> values); static boolean almostEquals(double a, double b); static boolean almostEquals(double a, double b, double epsilon);  }### Answer:
@Test public void parseLong() { assertEquals(0, NumberHelper.parseLong("abc")); assertEquals(1, NumberHelper.parseLong("1")); assertEquals(1, NumberHelper.parseLong("abc", 1)); assertEquals(-1, NumberHelper.parseLong("-1")); assertEquals(0, NumberHelper.parseLong("1a")); assertEquals(0, NumberHelper.parseLong("1 ")); assertEquals(0, NumberHelper.parseLong(" 1")); assertEquals(0, NumberHelper.parseLong("a1")); assertEquals(2, NumberHelper.parseLong(" 1", 2)); assertEquals(2, NumberHelper.parseLong("a1", 2)); assertEquals(2, NumberHelper.parseLong("1", 3, 2, 4)); assertEquals(bigLong, NumberHelper.parseLong("" + bigLong)); assertEquals(bigLong, NumberHelper.parseLong("" + (bigLong + 1), 0, 0, bigLong)); for (int i = 0; i < 20; i++) { assertEquals(i, NumberHelper.parseLong("" + (i))); assertEquals(-i, NumberHelper.parseLong("" + (-i))); assertEquals(Long.MIN_VALUE + i, NumberHelper.parseLong("" + (Long.MIN_VALUE + i))); assertEquals(Long.MAX_VALUE - i, NumberHelper.parseLong("" + (Long.MAX_VALUE - i))); } }