add comments

This commit is contained in:
Siarhei Fedartsou 2022-09-30 17:49:44 +02:00
parent 05c6008995
commit 4f222be7f2
2 changed files with 8 additions and 4 deletions

View File

@ -5,13 +5,14 @@
#include <iterator>
#include <string>
using osrm::util::escape_JSON;
using osrm::util::EscapeJSONString;
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size)
{
const std::string in(reinterpret_cast<const char *>(data), size);
const auto escaped = escape_JSON(in);
std::string escaped;
EscapeJSONString(in, escaped);
escape(escaped.data());
return 0;

View File

@ -12,12 +12,15 @@ using namespace osrm::util;
BOOST_AUTO_TEST_CASE(json_escaping)
{
std::string input{"\b\\"};
std::string output{escape_JSON(input)};
std::string output;
EscapeJSONString(input, output);
BOOST_CHECK_EQUAL(SizeOfEscapedJSONString(input), 4);
BOOST_CHECK_EQUAL(output, "\\b\\\\");
input = "Aleja \"Solidarnosci\"";
output = escape_JSON(input);
EscapeJSONString(input, output);
BOOST_CHECK_EQUAL(SizeOfEscapedJSONString(input), 24);
BOOST_CHECK_EQUAL(output, "Aleja \\\"Solidarnosci\\\"");
}