Use reference parser for tests

This commit is contained in:
2025-08-18 06:27:24 -04:00
parent 9e397d19c9
commit 34b5de1744
7 changed files with 961 additions and 792 deletions

View File

@@ -1,4 +1,6 @@
#include "test_data.hpp"
#include <simdutf.h>
#include <vector>
namespace weaseldb::test_data {
@@ -89,6 +91,21 @@ const std::string COMPLEX_JSON = R"({
]
})";
// Helper function to encode a string as base64
std::string encode_base64(const std::string &input) {
if (input.empty()) {
return "";
}
size_t max_output_size = simdutf::base64_length_from_binary(input.size());
std::vector<char> output(max_output_size);
size_t written = simdutf::binary_to_base64(
input.data(), input.size(), output.data(), simdutf::base64_default);
return std::string(output.data(), written);
}
// Generate a large JSON with many operations for stress testing
std::string generate_large_json(int num_operations) {
std::string json = R"({
@@ -101,13 +118,19 @@ std::string generate_large_json(int num_operations) {
for (int i = 0; i < num_operations; ++i) {
if (i > 0)
json += ",";
std::string key = "key" + std::to_string(i);
std::string value = "value" + std::to_string(i);
std::string key_b64 = encode_base64(key);
std::string value_b64 = encode_base64(value);
json += R"(
{
"type": "write",
"key": ")" +
std::string("key") + std::to_string(i) + R"(",
key_b64 + R"(",
"value": ")" +
std::string("value") + std::to_string(i) + R"("
value_b64 + R"("
})";
}