@Test
public void testECMA6UnicodeEscapeInString()
{

    JSONConfig cfg = new JSONConfig().setUseECMA6(true).setEscapeNonAscii(true)
                                     .setBadCharacterPolicy(JSONConfig.ESCAPE);
    StringBuilder buf = new StringBuilder();
    Set<Character> singles = new HashSet<>(Arrays.asList('\b','\t','\n','\f','\r'));
    Random rand = new Random();
    int bound = Character.MAX_CODE_POINT+1;
    int min = Character.MIN_SUPPLEMENTARY_CODE_POINT;
    for ( int i = 0; i < 4096; i++ ){
        int cp;
        do{
            cp = rand.nextInt(bound);
        }while ( cp > 0xF && cp < min );
        buf.setLength(0);
        buf.appendCodePoint(cp);
        String result;
        if ( cp < 0xF && singles.contains((char)cp) ){
            result = '"' + StringProcessor.getEscape((char)cp) + '"';
        }else{
            result = '"' + String.format("\\u{%X}", cp) + '"';
        }
        String json = JSONUtil.toJSON(buf, cfg);
        assertThat(json, is(result));
    }
}