EventToString { EventToString escapeSpecialChars(String arg) { for (int i = 0; i < arg.length(); i++) { escapeSpecialChar(arg.charAt(i)); } return this; } EventToString(Charset charset); static String format(String className, String methodName, Object... args); String build(); EventToString formatMethodCall(String className, String methodName, Object... args);  }
@Test public void shows_strings_using_string_literal_escape_sequences() { assertThat(escapeSpecialChars("\b"), is("\\b")); assertThat(escapeSpecialChars("\t"), is("\\t")); assertThat(escapeSpecialChars("\n"), is("\\n")); assertThat(escapeSpecialChars("\f"), is("\\f")); assertThat(escapeSpecialChars("\r"), is("\\r")); assertThat(escapeSpecialChars("\""), is("\\\"")); assertThat(escapeSpecialChars("\\"), is("\\\\")); }
@Test public void escapes_ISO_control_characters() { assertThat(escapeSpecialChars("\0"), is("\\u0000")); assertThat(escapeSpecialChars("\1"), is("\\u0001")); assertThat(escapeSpecialChars("\u001f"), is("\\u001f")); }
@Test public void escapes_unmappable_characters_for_the_current_charset() { assertThat(escapeSpecialChars("åäö", Charset.forName("ISO-8859-1")), is("åäö")); assertThat(escapeSpecialChars("åäö", Charset.forName("US-ASCII")), is("\\u00e5\\u00e4\\u00f6")); }