@Test
public void testExceptionSurrogates()
{

    JSONConfig cfg = new JSONConfig().setUseECMA6(false).setBadCharacterPolicy(JSONConfig.EXCEPTION);
    Random rand = new Random();
    for ( int i = 0; i <= BAD_CHARS; i++ ){
        char ch = getRandomSurrogate(rand);
        try{
            JSONUtil.toJSON(surrogateTestMap(ch), cfg);
            fail("Expected a UnmatchedSurrogateException to be thrown.");
        }catch ( UnmatchedSurrogateException e ){
            assertThat(e.getMessage(), containsString(String.format("Unmatched surrogate U+%04X at position", (int)ch)));
        }
    }
}