### Question:
Tags { public static long parseLong(final CharSequence s) { final int n = s.length(); if (n == 0) { throw new NumberFormatException("Empty string"); } char c = s.charAt(0); int i = 1; if (c < '0' && (c == '+' || c == '-')) { if (n == 1) { throw new NumberFormatException("Just a sign, no value: " + s); } else if (n > 20) { throw new NumberFormatException("Value too long: " + s); } c = s.charAt(1); i = 2; } else if (n > 19) { throw new NumberFormatException("Value too long: " + s); } long v = 0; do { if ('0' <= c && c <= '9') { v -= c - '0'; } else { throw new NumberFormatException("Invalid character '" + c + "' in " + s); } if (i == n) { break; } v *= 10; c = s.charAt(i++); } while (true); if (v > 0) { throw new NumberFormatException("Overflow in " + s); } else if (s.charAt(0) == '-') { return v; } else if (v == Long.MIN_VALUE) { throw new NumberFormatException("Overflow in " + s); } else { return -v; } } private  Tags(); static String[] splitString(final String s, final char c); static void parse(final HashMap<String, String> tags,
                             final String tag); static String parseWithMetric(final String metric,
                                         final HashMap<String, String> tags); static long parseLong(final CharSequence s); static boolean looksLikeInteger(final String value);  }### Answer:
@Test public void parseLongSimple() { assertEquals(0, Tags.parseLong("0")); assertEquals(0, Tags.parseLong("+0")); assertEquals(0, Tags.parseLong("-0")); assertEquals(1, Tags.parseLong("1")); assertEquals(1, Tags.parseLong("+1")); assertEquals(-1, Tags.parseLong("-1")); assertEquals(4242, Tags.parseLong("4242")); assertEquals(4242, Tags.parseLong("+4242")); assertEquals(-4242, Tags.parseLong("-4242")); }
@Test public void parseLongMaxValue() { assertEquals(Long.MAX_VALUE, Tags.parseLong(Long.toString(Long.MAX_VALUE))); }
@Test public void parseLongMinValue() { assertEquals(Long.MIN_VALUE, Tags.parseLong(Long.toString(Long.MIN_VALUE))); }
@Test(expected=NumberFormatException.class) public void parseLongEmptyString() { Tags.parseLong(""); }
@Test(expected=NumberFormatException.class) public void parseLongMalformed() { Tags.parseLong("42a51"); }
@Test(expected=NumberFormatException.class) public void parseLongMalformedPlus() { Tags.parseLong("+"); }
@Test(expected=NumberFormatException.class) public void parseLongMalformedMinus() { Tags.parseLong("-"); }
@Test(expected=NumberFormatException.class) public void parseLongValueTooLarge() { Tags.parseLong("18446744073709551616"); }
@Test(expected=NumberFormatException.class) public void parseLongValueTooLargeSubtle() { Tags.parseLong("9223372036854775808"); }
@Test(expected=NumberFormatException.class) public void parseLongValueTooSmallSubtle() { Tags.parseLong("-9223372036854775809"); }