Skip to content

Commit

Permalink
Add test using JDK enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed Jun 18, 2024
1 parent 431a5e6 commit e62cc06
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gson/src/test/java/com/google/gson/functional/EnumTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,15 @@ public String toString() {
return toString;
}
}

/**
* Verifies that the enum adapter works for a public JDK enum class and no {@code
* InaccessibleObjectException} is thrown, despite using reflection internally to account for the
* constant names possibly being obfuscated.
*/
@Test
public void testJdkEnum() {
assertThat(gson.toJson(Thread.State.NEW)).isEqualTo("\"NEW\"");
assertThat(gson.fromJson("\"NEW\"", Thread.State.class)).isEqualTo(Thread.State.NEW);
}
}

0 comments on commit e62cc06

Please sign in to comment.