MCPcopy Create free account
hub / github.com/boostorg/beast / testFuzz

Method testFuzz

test/beast/http/basic_parser.cpp:1209–1262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1207 //--------------------------------------------------------------------------
1208
1209 void
1210 testFuzz()
1211 {
1212 auto const grind =
1213 [&](string_view s)
1214 {
1215 static_string<100> ss(s.data(), s.size());
1216 test::fuzz_rand r;
1217 test::fuzz(ss, 4, 5, r,
1218 [&](string_view s)
1219 {
1220 error_code ec;
1221 test_parser<false> p;
1222 p.eager(true);
1223 p.put(net::const_buffer{
1224 s.data(), s.size()}, ec);
1225 });
1226 };
1227 auto const good =
1228 [&](string_view s)
1229 {
1230 std::string msg =
1231 "HTTP/1.1 200 OK\r\n"
1232 "Transfer-Encoding: chunked\r\n"
1233 "\r\n"
1234 "0" + std::string(s) + "\r\n"
1235 "\r\n";
1236 error_code ec;
1237 test_parser<false> p;
1238 p.eager(true);
1239 p.put(net::const_buffer{
1240 msg.data(), msg.size()}, ec);
1241 BEAST_EXPECTS(! ec, ec.message());
1242 grind(msg);
1243 };
1244 auto const bad =
1245 [&](string_view s)
1246 {
1247 std::string msg =
1248 "HTTP/1.1 200 OK\r\n"
1249 "Transfer-Encoding: chunked\r\n"
1250 "\r\n"
1251 "0" + std::string(s) + "\r\n"
1252 "\r\n";
1253 error_code ec;
1254 test_parser<false> p;
1255 p.eager(true);
1256 p.put(net::const_buffer{
1257 msg.data(), msg.size()}, ec);
1258 BEAST_EXPECT(ec);
1259 grind(msg);
1260 };
1261 chunkExtensionsTest(good, bad);
1262 }
1263
1264 //--------------------------------------------------------------------------
1265

Callers

nothing calls this directly

Calls 7

fuzzFunction · 0.85
chunkExtensionsTestFunction · 0.85
eagerMethod · 0.80
messageMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected