2016-01-02 11:13:44 -05:00
|
|
|
#include "util/string_util.hpp"
|
2015-03-27 13:15:58 -04:00
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2015-03-27 13:15:58 -04:00
|
|
|
|
2024-05-29 03:13:13 -04:00
|
|
|
#include <string>
|
2015-03-27 13:15:58 -04:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(string_util)
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
using namespace osrm;
|
|
|
|
using namespace osrm::util;
|
|
|
|
|
2015-03-27 13:15:58 -04:00
|
|
|
BOOST_AUTO_TEST_CASE(json_escaping)
|
|
|
|
{
|
2015-04-02 04:34:40 -04:00
|
|
|
std::string input{"\b\\"};
|
2022-10-03 15:43:51 -04:00
|
|
|
std::string output;
|
|
|
|
EscapeJSONString(input, output);
|
2015-03-27 13:15:58 -04:00
|
|
|
|
2022-10-03 15:43:51 -04:00
|
|
|
BOOST_CHECK(RequiresJSONStringEscaping(input));
|
2015-03-27 13:15:58 -04:00
|
|
|
BOOST_CHECK_EQUAL(output, "\\b\\\\");
|
2015-04-02 04:34:40 -04:00
|
|
|
|
|
|
|
input = "Aleja \"Solidarnosci\"";
|
2022-10-03 15:43:51 -04:00
|
|
|
output.clear();
|
|
|
|
EscapeJSONString(input, output);
|
|
|
|
BOOST_CHECK(RequiresJSONStringEscaping(input));
|
2015-04-02 04:34:40 -04:00
|
|
|
BOOST_CHECK_EQUAL(output, "Aleja \\\"Solidarnosci\\\"");
|
2022-10-03 15:43:51 -04:00
|
|
|
|
|
|
|
BOOST_CHECK(!RequiresJSONStringEscaping("Aleja Solidarnosci"));
|
2015-03-27 13:15:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|