| 1428 | } |
| 1429 | |
| 1430 | void |
| 1431 | testUTF16Validation() |
| 1432 | { |
| 1433 | // Invalid surrogate pair cases |
| 1434 | TEST_BAD("{\"command\":\"\\uDF3E\\uDEC2\"}"); // Illegal leading surrogate |
| 1435 | TEST_BAD("{\"command\":\"\\uD83D\\uD83D\"}"); // Illegal trailing surrogate |
| 1436 | TEST_BAD("{\"command\":\"\\uDF3E\\uD83D\"}"); // Illegal leading & trailing surrogate |
| 1437 | TEST_BAD("{\"command\":\"\\uD83D\"}"); // Half a surrogate (Valid leading surrogate) |
| 1438 | TEST_BAD("{\"command\":\"\\uDF3E\"}"); // Half a surrogate (Illegal leading surrogate) |
| 1439 | |
| 1440 | // Allow invalid UTF-16 |
| 1441 | parse_options opt; |
| 1442 | opt.allow_invalid_utf16 = true; |
| 1443 | |
| 1444 | TEST_GOOD_EXT("{\"command\":\"\\uDF3E\\uDEC2\"}", opt); // Illegal leading surrogate |
| 1445 | TEST_GOOD_EXT("{\"command\":\"\\uD83D\\uD83D\"}", opt); // Illegal trailing surrogate |
| 1446 | TEST_GOOD_EXT("{\"command\":\"\\uDF3E\\uD83D\"}", opt); // Illegal leading & trailing surrogate |
| 1447 | TEST_GOOD_EXT("{\"command\":\"\\uD83D\"}", opt); // Half a surrogate (Valid leading surrogate) |
| 1448 | TEST_GOOD_EXT("{\"command\":\"\\uDF3E\"}", opt); // Half a surrogate (Illegal leading surrogate) |
| 1449 | TEST_GOOD_EXT("{\"command\":\"\\uD800uDC00\"}", opt); // Unseparated surrogates |
| 1450 | TEST_GOOD_EXT("{\"command\":\"\\uD800\\n\"}", opt); // Half a surrogate (Valid leading surrogate), followed by a newline character |
| 1451 | TEST_GOOD_EXT("{\"command\":\"\\uD800\\n\\uDC00\"}", opt); // Half a surrogate (Valid leading surrogate), followed by a newline character, followed by a half surrogate |
| 1452 | TEST_GOOD_EXT("{\"command\":\"\\uD800\\uD800\\uDC00\"}", opt); // Half a surrogate (Valid leading surrogate), followed by a valid surrogate pair |
| 1453 | TEST_GOOD_EXT("{\"command\":\"\\uDC00\\uD800\\uDC00\"}", opt); // Half a surrogate (Illegal leading surrogate), followed by a valid surrogate pair |
| 1454 | TEST_GOOD_EXT("{\"command\":\"\\uD800\\uE000\\uDC00\"}", opt); // Half a surrogate (Valid leading surrogate), followed by a valid utf-8, followed by a half surrogate |
| 1455 | TEST_GOOD_EXT("{\"command\":\"\\uD800\\uDC00\\uD800\\uE000\"}", opt); // Valid surrogate pair, followed by a half surrogate, followed by a valid utf-8 |
| 1456 | TEST_GOOD_EXT("{\"command\":\"\\uD800\\uDC00\\uD800\\uD800\\uDC00\"}", opt); // Valid surrogate pair, followed by a half surrogate, followed by a valid surrogate pair |
| 1457 | } |
| 1458 | |
| 1459 | void |
| 1460 | testMaxDepth() |