Skip to content

Commit

Permalink
Add a test for #3171
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 8, 2021
1 parent 9cfcf8d commit b65606d
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ public void testWithFailOnNumbersAndReadUnknownAsDefault()
_verifyOkDeserialization(r, "2", CustomEnumWithDefault.class, CustomEnumWithDefault.ZERO);
}

// [databind#3171]: Ensure "" gets returned as Default Value, not coerced
public void testEmptyStringAsDefault() throws Exception
{
ObjectReader r = MAPPER.readerFor(SimpleEnumWithDefault.class)
.with(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
assertEquals(SimpleEnumWithDefault.ONE,
r.readValue(quote("ONE")));
assertEquals(SimpleEnumWithDefault.ZERO,
r.readValue(quote("Zero")));
assertEquals(SimpleEnumWithDefault.ZERO,
r.readValue(quote("")));
}

private <T> void _verifyOkDeserialization(ObjectReader reader, String fromValue,
Class<T> toValueType, T expValue)
throws IOException
Expand Down

0 comments on commit b65606d

Please sign in to comment.