19#include <boost/test/unit_test.hpp>
43 std::string parse(string_view
data)
45 for (
const auto c :
data) {
55 }
catch (
const exception& e) {
70 if (!result_.empty() && result_.back() !=
'[') {
79 if (!result_.empty() && result_.back() !=
'[') {
88 if (!result_.empty() && result_.back() !=
'[') {
97 if (!result_.empty() && result_.back() !=
'[') {
122std::string parse(string_view
data)
125 return p.parse(
data);
147 "-ERR unknown command 'foobar'");
177 BOOST_CHECK_EQUAL(parse(
"+OK\r\n-ERR\r\n:123\r\n$6\r\nfoobar\r\n"sv),
"+OK,-ERR,:123,+foobar");
188 BOOST_CHECK(parse(
"*5\r\n:1\r\n:2\r\n:3\r\n:4\r\n$6\r\nfoobar\r\n"sv)
189 ==
"[:1,:2,:3,:4,+foobar]");
190 BOOST_CHECK(parse(
"*5\r\n:1\r\n:2\r\n:3!\r\n:4\r\n$6\r\nfoobar\r\n+OK\r\n"sv)
205 BOOST_CHECK(parse(
"*3\r\n:1\r\n*3\r\n:11\r\n*2\r\n:111\r\n:222\r\n:22\r\n:2\r\n"sv)
206 ==
"[:1,[:11,[:111,:222],:22],:2]");
207 BOOST_CHECK(parse(
"*3\r\n:1\r\n*3\r\n:11\r\n*2\r\n:111!\r\n:222\r\n:22\r\n:2\r\n+OK\r\n"sv)
208 ==
"[:1,[:11,[!~,+OK");
BOOST_CHECK_EQUAL(v.size(), 10U)
BOOST_AUTO_TEST_CASE(SimpleStringCase)
BOOST_CHECK(isnan(stod(""sv, numeric_limits< double >::quiet_NaN())))