@@ -14,6 +14,11 @@ static constexpr char lbl[] = "0123456789";
1414#define validate (A, B ) BOOST_TEST(std::string_view(A.c_str(), A.length()) == std::string_view(B))
1515#define check (A, B ) BOOST_TEST(A == B)
1616
17+ static constexpr string::size_type length (const std::string_view& str) noexcept
18+ {
19+ return static_cast <string::size_type>(str.length ());
20+ }
21+
1722BOOST_AUTO_TEST_CASE (StringInitializeTest)
1823{
1924 string a;
@@ -614,15 +619,15 @@ BOOST_AUTO_TEST_SUITE(MoveSematicsTests)
614619// Move only big strings in the same pool
615620BOOST_AUTO_TEST_CASE(DefaultPoolMoveTest)
616621{
617- string sourceString (BigStringValue.data (), BigStringValue. length ());
622+ string sourceString (BigStringValue.data (), length (BigStringValue ));
618623
619624 // Move c'tor
620625 string newString (std::move (sourceString));
621626 checkMovedString (sourceString);
622627 testBigString (newString);
623628
624629 // Reuse
625- sourceString.assign (BigStringValue.data (), BigStringValue. length ());
630+ sourceString.assign (BigStringValue.data (), length (BigStringValue ));
626631 testBigString (sourceString);
627632
628633 // Move assignment
@@ -634,15 +639,15 @@ BOOST_AUTO_TEST_CASE(DefaultPoolMoveTest)
634639BOOST_AUTO_TEST_CASE (NewPoolMoveTest)
635640{
636641 AutoMemoryPool pool (MemoryPool::createPool ());
637- string sourceString (*pool, BigStringValue.data (), BigStringValue. length ());
642+ string sourceString (*pool, BigStringValue.data (), length (BigStringValue ));
638643
639644 // Move c'tor
640645 string newString (*pool, std::move (sourceString));
641646 checkMovedString (sourceString);
642647 testBigString (newString);
643648
644649 // Reuse
645- sourceString.assign (BigStringValue.data (), BigStringValue. length ());
650+ sourceString.assign (BigStringValue.data (), length (BigStringValue ));
646651 testBigString (sourceString);
647652
648653 // Move assignment
@@ -660,15 +665,15 @@ BOOST_AUTO_TEST_SUITE(CannotMoveTests)
660665BOOST_AUTO_TEST_CASE(DifferentVsDefaultPoolMove)
661666{
662667 AutoMemoryPool pool (MemoryPool::createPool ());
663- string sourceString (*pool, BigStringValue.data (), BigStringValue. length ());
668+ string sourceString (*pool, BigStringValue.data (), length (BigStringValue ));
664669
665670 // Move c'tor
666671 string newString (std::move (sourceString));
667672 testBigString (sourceString);
668673 testBigString (newString);
669674
670675 // Reuse
671- sourceString.assign (BigStringValue.data (), BigStringValue. length ());
676+ sourceString.assign (BigStringValue.data (), length (BigStringValue ));
672677 testBigString (sourceString);
673678
674679 // Move assignment
@@ -682,15 +687,15 @@ BOOST_AUTO_TEST_CASE(DifferentPoolsMove)
682687{
683688 AutoMemoryPool pool1 (MemoryPool::createPool ());
684689 AutoMemoryPool pool2 (MemoryPool::createPool ());
685- string sourceString (*pool1, BigStringValue.data (), BigStringValue. length ());
690+ string sourceString (*pool1, BigStringValue.data (), length (BigStringValue ));
686691
687692 // Move c'tor
688693 string newString (*pool2, std::move (sourceString));
689694 testBigString (sourceString);
690695 testBigString (newString);
691696
692697 // Reuse
693- sourceString.assign (BigStringValue.data (), BigStringValue. length ());
698+ sourceString.assign (BigStringValue.data (), length (BigStringValue ));
694699 testBigString (sourceString);
695700
696701 // Move assignment
@@ -702,15 +707,15 @@ BOOST_AUTO_TEST_CASE(DifferentPoolsMove)
702707// Do not move
703708BOOST_AUTO_TEST_CASE (SmallStringMove)
704709{
705- string sourceString (SmallStringValue.data (), SmallStringValue. length ());
710+ string sourceString (SmallStringValue.data (), length (SmallStringValue ));
706711
707712 // Move c'tor
708713 string newString (std::move (sourceString));
709714 testSmallString (sourceString);
710715 testSmallString (newString);
711716
712717 // Reuse
713- sourceString.assign (SmallStringValue.data (), SmallStringValue. length ());
718+ sourceString.assign (SmallStringValue.data (), length (SmallStringValue ));
714719 testSmallString (sourceString);
715720
716721 // Move assign
0 commit comments