@Test
public void testWriteJsonString() throws IOException {

    int numTested = 0;
    int numBaddish = 0;
    for (int codePoint = 0; codePoint <= MAX_CODE_POINT; codePoint++) {
        try {
            final String codePointStr = stringForCodePoint(codePoint);
            if (codePoint < 32) {
                final String expected = '"' + String.format("\\u%04x", codePoint) + '"';
                checkByteArrays(B2StringUtil.getUtf8Bytes(expected), convertForJsonString(codePointStr));
            } else if (codePoint == '"') {
                // in json, it should be "\"", so...
                final byte[] expected = { '"', '\\', '"', '"'};
                checkByteArrays(expected, convertForJsonString(codePointStr));
            } else if (codePoint == '\\') {
                // in json, it should be "\\", so...
                final byte[] expected = { '"', '\\', '\\', '"'};
                checkByteArrays(expected, convertForJsonString(codePointStr));
            } else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
                checkBadSurrogateLikeCodePointForJsonString(codePointStr);
                numBaddish++;
            } else {
                checkValidCodePointForJsonString(codePointStr);
            }
            numTested++;
        } catch (Throwable t) {
            throw new RuntimeException("trouble for codePoint " + codePointNum(codePoint) + ": " + t, t);
        }
    }
    System.err.println("testWriteJsonString: tested " + numTested + " code points, including " + numBaddish + " bad-ish ones.");
}