@Test
public void testEscape() {

    assertEscaped("hello", "hello", false);
    assertEscaped("hello, world", "hello, world", false);
    assertEscaped("hello, world", "hello\\, world", true);
    assertEscaped("[hello]", "\\[hello]", false);
    assertEscaped("[hello]", "[hello]", true);
    assertEscaped("{hello}", "\\{hello}", false);
    assertEscaped("{hello}", "{hello}", true);
    assertEscaped("hello\u000fworld", "hello\\u000fworld", false);
    assertEscaped("hello\u000fworld", "hello\\u000fworld", true);
    assertEscaped("hello\\world", "hello\\\\world", false);
    assertEscaped("hello\\world", "hello\\\\world", true);
}