Skip to content

Commit a7ee069

Browse files
andrey-qlogicsduskis
authored andcommitted
Added unit tests for null enum and unknown enum. (#602)
1 parent b466220 commit a7ee069

File tree

1 file changed

+19
-0
lines changed
  • google-http-client/src/test/java/com/google/api/client/util

1 file changed

+19
-0
lines changed

google-http-client/src/test/java/com/google/api/client/util/DataTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ public void testParsePrimitiveValue() {
242242
// expected
243243
}
244244
assertNull(Data.parsePrimitiveValue(Void.class, "abc"));
245+
assertNull(Data.parsePrimitiveValue(Enum.class, null));
246+
}
247+
248+
private enum MyEnum {
249+
A("a");
250+
private final String s;
251+
252+
MyEnum(String s) {
253+
this.s = s;
254+
}
255+
}
256+
257+
public void testParsePrimitiveValueWithUnknownEnum() {
258+
try {
259+
Data.parsePrimitiveValue(MyEnum.class, "foo");
260+
fail("expected " + IllegalArgumentException.class);
261+
} catch (IllegalArgumentException e) {
262+
// expected
263+
}
245264
}
246265

247266
static class Resolve<X, T extends Number> {

0 commit comments

Comments
 (0)