Check that all callbacks are invoked
| 361 | |
| 362 | // Check that all callbacks are invoked |
| 363 | void |
| 364 | testCallbacks() |
| 365 | { |
| 366 | parsegrind<test_parser<true>>( |
| 367 | "GET / HTTP/1.1\r\n" |
| 368 | "\r\n", |
| 369 | [&](test_parser<true> const& p) |
| 370 | { |
| 371 | BEAST_EXPECT(p.got_on_begin == 1); |
| 372 | BEAST_EXPECT(p.got_on_field == 0); |
| 373 | BEAST_EXPECT(p.got_on_header == 1); |
| 374 | BEAST_EXPECT(p.got_on_body == 0); |
| 375 | BEAST_EXPECT(p.got_on_chunk == 0); |
| 376 | BEAST_EXPECT(p.got_on_complete == 1); |
| 377 | }); |
| 378 | parsegrind<test_parser<true>>( |
| 379 | "GET / HTTP/1.1\r\n" |
| 380 | "User-Agent: test\r\n" |
| 381 | "Content-Length: 1\r\n" |
| 382 | "\r\n" |
| 383 | "*", |
| 384 | [&](test_parser<true> const& p) |
| 385 | { |
| 386 | BEAST_EXPECT(p.got_on_begin == 1); |
| 387 | BEAST_EXPECT(p.got_on_field == 2); |
| 388 | BEAST_EXPECT(p.got_on_header == 1); |
| 389 | BEAST_EXPECT(p.got_on_body == 1); |
| 390 | BEAST_EXPECT(p.got_on_chunk == 0); |
| 391 | BEAST_EXPECT(p.got_on_complete == 1); |
| 392 | }); |
| 393 | parsegrind<test_parser<false>>( |
| 394 | "HTTP/1.1 100 Continue\r\n" |
| 395 | "\r\n", |
| 396 | [&](test_parser<false> const& p) |
| 397 | { |
| 398 | BEAST_EXPECT(p.got_on_begin == 1); |
| 399 | BEAST_EXPECT(p.got_on_field == 0); |
| 400 | BEAST_EXPECT(p.got_on_header == 1); |
| 401 | BEAST_EXPECT(p.got_on_body == 0); |
| 402 | BEAST_EXPECT(p.got_on_chunk == 0); |
| 403 | BEAST_EXPECT(p.got_on_complete == 1); |
| 404 | }); |
| 405 | parsegrind<test_parser<false>>( |
| 406 | "HTTP/1.1 200 OK\r\n" |
| 407 | "Server: test\r\n" |
| 408 | "Content-Length: 1\r\n" |
| 409 | "\r\n" |
| 410 | "*", |
| 411 | [&](test_parser<false> const& p) |
| 412 | { |
| 413 | BEAST_EXPECT(p.got_on_begin == 1); |
| 414 | BEAST_EXPECT(p.got_on_field == 2); |
| 415 | BEAST_EXPECT(p.got_on_header == 1); |
| 416 | BEAST_EXPECT(p.got_on_body == 1); |
| 417 | BEAST_EXPECT(p.got_on_chunk == 0); |
| 418 | BEAST_EXPECT(p.got_on_complete == 1); |
| 419 | }); |
| 420 | parsegrind<test_parser<false>>( |
nothing calls this directly
no outgoing calls
no test coverage detected