Add utf-8 unescaping test

This commit is contained in:
2025-05-19 13:14:24 -04:00
parent d9bb22e6b1
commit 19bc216458

View File

@@ -208,7 +208,7 @@ TEST_CASE("parser3") {
TEST_CASE("streaming") { testStreaming(json); }
TEST_CASE("unescaping") {
TEST_CASE("unescaping basic") {
auto c = noopCallbacks();
c.on_string_data = +[](void *, const char *buf, int len) {
CHECK(std::string(buf, len) == "\n");
@@ -219,6 +219,17 @@ TEST_CASE("unescaping") {
CHECK(parser.parse(nullptr, 0) == parser3::S_OK);
}
TEST_CASE("unescaping utf-8") {
auto c = noopCallbacks();
c.on_string_data = +[](void *, const char *buf, int len) {
CHECK(std::string(buf, len) == "\uaB34");
};
std::string copy = "\"\\uaB34\"";
parser3::Parser3 parser(&c, nullptr);
CHECK(parser.parse(copy.data(), copy.length()) == parser3::S_AGAIN);
CHECK(parser.parse(nullptr, 0) == parser3::S_OK);
}
TEST_CASE("bench3") {
auto c = noopCallbacks();
ankerl::nanobench::Bench bench;