### Question:
DoubleType implements Type, Serializable { @Override public Object cast(Object obj) { Double value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).doubleValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? 1.0 : 0.0; } else if (obj instanceof String) { try { value = Double.valueOf((String) obj); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return value; } private  DoubleType(); @Override String getName(); @Override boolean supportsEq(); @Override boolean supportsOrdering(); @Override JsonNode toJson(JsonNodeFactory factory, Object obj); @Override Object cast(Object obj); @SuppressWarnings({"rawtypes", "unchecked"}) @Override int compare(Object v1, Object v2); @Override Object fromJson(JsonNode node); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final Type TYPE; static final String NAME; }### Answer:
@Test public void testCastNull() { assertNull(doubleType.cast(null)); }
@Test public void testCastBigDecimal() { assertTrue(doubleType.cast(Double.MAX_VALUE) instanceof Double); }
@Test public void testCastDouble() { assertTrue(doubleType.cast(Double.MAX_VALUE) instanceof Double); }
@Test public void testCastFloat() { assertTrue(doubleType.cast(Float.MAX_VALUE) instanceof Double); }
@Test public void testCastLong() { Long laung = Long.MAX_VALUE; assertTrue(doubleType.cast(laung) instanceof Double); }
@Test public void testCastBooleanTrue() { assertTrue(doubleType.cast(Boolean.TRUE) instanceof Double); }
@Test public void testCastBooleanFalse() { assertTrue(doubleType.cast(Boolean.FALSE) instanceof Double); }
@Test public void testCastGoodString() { assertTrue(doubleType.cast("8675309") instanceof Double); }
@Test(expected = Error.class) public void testCastBadString() { doubleType.cast("string"); }
@Test(expected = Error.class) public void testCcastOther() { doubleType.cast(new Object()); }