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

Method testAccess

test/beast/core/static_string.cpp:414–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412 }
413
414 void
415 testAccess()
416 {
417 {
418 static_string<5> s("12345");
419 BEAST_EXPECT(s.at(1) == '2');
420 BEAST_EXPECT(s.at(4) == '5');
421 try
422 {
423 BEAST_EXPECT(s.at(5) == 0);
424 fail("", __FILE__, __LINE__);
425 }
426 catch(std::out_of_range const&)
427 {
428 pass();
429 }
430 }
431 {
432 static_string<5> const s("12345");
433 BEAST_EXPECT(s.at(1) == '2');
434 BEAST_EXPECT(s.at(4) == '5');
435 try
436 {
437 BEAST_EXPECT(s.at(5) == 0);
438 fail("", __FILE__, __LINE__);
439 }
440 catch(std::out_of_range const&)
441 {
442 pass();
443 }
444 }
445 {
446 static_string<5> s("12345");
447 BEAST_EXPECT(s[1] == '2');
448 BEAST_EXPECT(s[4] == '5');
449 s[1] = '_';
450 BEAST_EXPECT(s == "1_345");
451 }
452 {
453 static_string<5> const s("12345");
454 BEAST_EXPECT(s[1] == '2');
455 BEAST_EXPECT(s[4] == '5');
456 BEAST_EXPECT(s[5] == 0);
457 }
458 {
459 static_string<3> s("123");
460 BEAST_EXPECT(s.front() == '1');
461 BEAST_EXPECT(s.back() == '3');
462 s.front() = '_';
463 BEAST_EXPECT(s == "_23");
464 s.back() = '_';
465 BEAST_EXPECT(s == "_2_");
466 }
467 {
468 static_string<3> const s("123");
469 BEAST_EXPECT(s.front() == '1');
470 BEAST_EXPECT(s.back() == '3');
471 }

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
failFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected