Skip to content

Commit

Permalink
Temporarily add test-debugging code.
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnmcmanus committed Jul 26, 2023
1 parent e06bb0c commit 9c71200
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,21 @@ private static TypeAdapter<Date> dateAdapter(TypeAdapterFactory adapterFactory)

private static void assertFormatted(String formattedPattern, TypeAdapterFactory adapterFactory) {
TypeAdapter<Date> adapter = dateAdapter(adapterFactory);
assertThat(adapter.toJson(new Date(0))).matches(toLiteral(formattedPattern));
String json = adapter.toJson(new Date(0));
try {
assertThat(json).matches(toLiteral(formattedPattern));
} catch (AssertionError e) {
char[] chars = json.toCharArray();
for (char c : chars) {
if (c >= ' ' && c <= '~') {
System.err.print(c);
} else {
System.err.printf("\\u%04x", (int) c);
}
}
System.err.println();
throw e;
}
}

@SuppressWarnings("UndefinedEquals")
Expand Down

0 comments on commit 9c71200

Please sign in to comment.