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

Method testContainer

test/beast/http/fields.cpp:366–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364 }
365
366 void
367 testContainer()
368 {
369 {
370 // group fields
371 fields f;
372 f.insert(field::age, "1");
373 f.insert(field::cookie, "2");
374 f.insert(field::from, "3");
375 f.insert(field::cookie, "4");
376 BEAST_EXPECT(std::next(f.begin(), 0)->name() == field::age);
377 BEAST_EXPECT(std::next(f.begin(), 1)->name() == field::cookie);
378 BEAST_EXPECT(std::next(f.begin(), 2)->name() == field::cookie);
379 BEAST_EXPECT(std::next(f.begin(), 3)->name() == field::from);
380 BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "Age");
381 BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "Cookie");
382 BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "Cookie");
383 BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "From");
384 BEAST_EXPECT(std::next(f.begin(), 0)->value() == "1");
385 BEAST_EXPECT(std::next(f.begin(), 1)->value() == "2");
386 BEAST_EXPECT(std::next(f.begin(), 2)->value() == "4");
387 BEAST_EXPECT(std::next(f.begin(), 3)->value() == "3");
388 BEAST_EXPECT(f.erase(field::cookie) == 2);
389 BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "Age");
390 BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "From");
391 }
392 {
393 // group fields, case insensitive
394 fields f;
395 f.insert("a", "1");
396 f.insert("ab", "2");
397 f.insert("b", "3");
398 f.insert("AB", "4");
399 BEAST_EXPECT(std::next(f.begin(), 0)->name() == field::unknown);
400 BEAST_EXPECT(std::next(f.begin(), 1)->name() == field::unknown);
401 BEAST_EXPECT(std::next(f.begin(), 2)->name() == field::unknown);
402 BEAST_EXPECT(std::next(f.begin(), 3)->name() == field::unknown);
403 BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
404 BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "ab");
405 BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "AB");
406 BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "b");
407 BEAST_EXPECT(std::next(f.begin(), 0)->value() == "1");
408 BEAST_EXPECT(std::next(f.begin(), 1)->value() == "2");
409 BEAST_EXPECT(std::next(f.begin(), 2)->value() == "4");
410 BEAST_EXPECT(std::next(f.begin(), 3)->value() == "3");
411 BEAST_EXPECT(f.erase("Ab") == 2);
412 BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
413 BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "b");
414 }
415 {
416 // verify insertion orde
417 fields f;
418 f.insert( "a", "1");
419 f.insert("dd", "2");
420 f.insert("b", "3");
421 f.insert("dD", "4");
422 f.insert("c", "5");
423 f.insert("Dd", "6");

Callers

nothing calls this directly

Calls 4

insertMethod · 0.45
nameMethod · 0.45
beginMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected