### Question:
XSDPrimitiveTypeParser { public static double parseDouble(final Reader reader) throws IOException { boolean isNegative = false; boolean isNegativeExp = false; long decimal = 0; double fraction = 0; long exp = 0; int c = reader.read(); if (c == 'N') { return parseNaN(reader); } if (isSign(c)) { isNegative = (c == '-') ? true : false; c = reader.read(); } if (c == 'I') { return parseINF(reader, isNegative); } if (((c < '0') || (c > '9')) && (c != '.')) { throw new NumberFormatException("Invalid double value"); } while (c != -1 && c != '.' && (c != 'E' && c != 'e')) { decimal = accumulateLongDecimal(c, decimal); c = reader.read(); } if ((decimal == Long.MIN_VALUE) && !isNegative) { throw new NumberFormatException("Double overflow"); } if (!isNegative) { decimal = -decimal; } if (c == -1) { return decimal; } if (c == '.') { c = reader.read(); double base = 0.1; while (c != -1 && (c != 'E' && c != 'e')) { fraction = accumulateDoubleFraction(c, fraction, base); base *= 0.1; c = reader.read(); } } if (c == -1) { return decimal + fraction; } c = reader.read(); if (isSign(c)) { isNegativeExp = (c == '-') ? true : false; c = reader.read(); } while (c != -1) { exp = accumulateLongDecimal(c, exp); c = reader.read(); } if (!isNegativeExp) { exp = -exp; } return (decimal + fraction) * Math.pow(10, exp); }  static short parseShort(final Reader reader); static int parseInt(final Reader reader); static long parseLong(final Reader reader); static float parseFloat(final Reader reader); static double parseDouble(final Reader reader);  }### Answer:
@Test public void testGoodDouble() throws IOException { for (final String s : goodDoubleStrings) { try { checkDouble(s, XSDPrimitiveTypeParser.parseDouble(new StringReader(s))); } catch (final NumberFormatException e) { throw new RuntimeException("parseDouble failed. " + "String:" + s + ". " + e.getMessage()); } } }
@Test public void testSpecialDouble() throws IOException { assertTrue(Double.isNaN(XSDPrimitiveTypeParser.parseDouble(new StringReader("NaN")))); assertEquals(Double.POSITIVE_INFINITY, XSDPrimitiveTypeParser.parseDouble(new StringReader("INF")), 0); assertEquals(Double.POSITIVE_INFINITY, XSDPrimitiveTypeParser.parseDouble(new StringReader("+INF")), 0); assertEquals(Double.NEGATIVE_INFINITY, XSDPrimitiveTypeParser.parseDouble(new StringReader("-INF")), 0); }
@Test(expected=NumberFormatException.class) public void testOverflowMaxDouble() throws IOException { XSDPrimitiveTypeParser.parseDouble(new StringReader("9223372036854775808")); }
@Test(expected=NumberFormatException.class) public void testOverflowMinDouble() throws IOException { XSDPrimitiveTypeParser.parseDouble(new StringReader("-9223372036854775809")); }
@Test(expected=NumberFormatException.class) public void testInvalidDouble() throws IOException { XSDPrimitiveTypeParser.parseDouble(new StringReader("fdsk")); }
@Test(expected=NumberFormatException.class) public void testInvalidDoubleFraction() throws IOException { XSDPrimitiveTypeParser.parseDouble(new StringReader("123.asd")); }