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

Method testOperations

test/beast/core/static_string.cpp:553–1150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551 }
552
553 void
554 testOperations()
555 {
556 //
557 // clear
558 //
559
560 {
561 static_string<3> s("123");
562 s.clear();
563 BEAST_EXPECT(s.empty());
564 BEAST_EXPECT(*s.end() == 0);
565 }
566
567 //
568 // insert
569 //
570
571 {
572 // Using 7 as the size causes a miscompile in MSVC14.2 x64 Release
573 static_string<8> s1("12345");
574 s1.insert(2, 2, '_');
575 BEAST_EXPECT(s1 == "12__345");
576 BEAST_EXPECT(*s1.end() == 0);
577 try
578 {
579 static_string<6> s2("12345");
580 s2.insert(2, 2, '_');
581 fail("", __FILE__, __LINE__);
582 }
583 catch(std::length_error const&)
584 {
585 pass();
586 }
587 try
588 {
589 static_string<6> s2("12345");
590 s2.insert(6, 2, '_');
591 fail("", __FILE__, __LINE__);
592 }
593 catch(std::out_of_range const&)
594 {
595 pass();
596 }
597 }
598 {
599 static_string<7> s1("12345");
600 s1.insert(2, "__");
601 BEAST_EXPECT(s1 == "12__345");
602 BEAST_EXPECT(*s1.end() == 0);
603 try
604 {
605 static_string<6> s2("12345");
606 s2.insert(2, "__");
607 fail("", __FILE__, __LINE__);
608 }
609 catch(std::length_error const&)
610 {

Callers

nothing calls this directly

Calls 6

failFunction · 0.50
clearMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected