Add missing calls when testing for exceptions. (#1948)

This commit is contained in:
Éamonn McManus 2021-08-31 15:03:45 -07:00 committed by GitHub
parent 1a2e58a42f
commit c8f26dc907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,7 +90,9 @@ public class DefaultTypeAdaptersTest extends TestCase {
public void testClassSerialization() {
try {
gson.toJson(String.class);
} catch (UnsupportedOperationException expected) {}
fail();
} catch (UnsupportedOperationException expected) {
}
// Override with a custom type adapter for class.
gson = new GsonBuilder().registerTypeAdapter(Class.class, new MyClassTypeAdapter()).create();
assertEquals("\"java.lang.String\"", gson.toJson(String.class));
@ -99,7 +101,9 @@ public class DefaultTypeAdaptersTest extends TestCase {
public void testClassDeserialization() {
try {
gson.fromJson("String.class", String.class.getClass());
} catch (UnsupportedOperationException expected) {}
fail();
} catch (UnsupportedOperationException expected) {
}
// Override with a custom type adapter for class.
gson = new GsonBuilder().registerTypeAdapter(Class.class, new MyClassTypeAdapter()).create();
assertEquals(String.class, gson.fromJson("java.lang.String", Class.class));