@@ -45,6 +45,8 @@ class TestUtils : public TestFixture {
4545 TEST_CASE (as_const);
4646 TEST_CASE (memoize);
4747 TEST_CASE (endsWith);
48+ TEST_CASE (stringConcat);
49+ TEST_CASE (stringPrepend);
4850 }
4951
5052 void isValidGlobPattern () const {
@@ -575,6 +577,126 @@ class TestUtils : public TestFixture {
575577 ASSERT (!::endsWith (" tes" , " test" ));
576578 ASSERT (!::endsWith (" 2test" , " 2" ));
577579 }
580+
581+ void stringConcat () const
582+ {
583+ {
584+ std::string s = " 0" ;
585+ utils::string::concat (s, " a" );
586+ utils::string::concat (s, " b" );
587+ utils::string::concat (s, " c" );
588+ ASSERT_EQUALS (" 0abc" , s);
589+ }
590+ {
591+ std::string s = " 0" ;
592+ utils::string::concat (s, " a" , " b" , " c" );
593+ ASSERT_EQUALS (" 0abc" , s);
594+ }
595+ {
596+ const std::string a_str = " a" ;
597+ const std::string b_str = " b" ;
598+ const std::string c_str = " c" ;
599+ {
600+ std::string s = " 0" ;
601+ utils::string::concat (s, a_str);
602+ utils::string::concat (s, b_str);
603+ utils::string::concat (s, c_str);
604+ ASSERT_EQUALS (" 0abc" , s);
605+ }
606+ {
607+ std::string s = " 0" ;
608+ utils::string::concat (s, a_str, b_str, c_str);
609+ ASSERT_EQUALS (" 0abc" , s);
610+ }
611+ }
612+ {
613+ std::string s = " 0" ;
614+ utils::string::concat (s, ' a' );
615+ utils::string::concat (s, ' b' );
616+ utils::string::concat (s, ' c' );
617+ ASSERT_EQUALS (" 0abc" , s);
618+ }
619+ {
620+ std::string s = " 0" ;
621+ utils::string::concat (s, ' a' , ' b' , ' c' );
622+ ASSERT_EQUALS (" 0abc" , s);
623+ }
624+ {
625+ const std::string a_str = " a" ;
626+ {
627+ std::string s = " 0" ;
628+ utils::string::concat (s, a_str);
629+ utils::string::concat (s, ' b' );
630+ utils::string::concat (s, " c" );
631+ ASSERT_EQUALS (" 0abc" , s);
632+ }
633+ {
634+ std::string s = " 0" ;
635+ utils::string::concat (s, a_str, ' b' , " c" );
636+ ASSERT_EQUALS (" 0abc" , s);
637+ }
638+ }
639+ }
640+
641+ void stringPrepend () const
642+ {
643+ {
644+ std::string s = " 0" ;
645+ utils::string::prepend (s, " a" );
646+ utils::string::prepend (s, " b" );
647+ utils::string::prepend (s, " c" );
648+ ASSERT_EQUALS (" cba0" , s);
649+ }
650+ {
651+ std::string s = " 0" ;
652+ utils::string::prepend (s, " a" , " b" , " c" );
653+ ASSERT_EQUALS (" abc0" , s);
654+ }
655+ {
656+ const std::string a_str = " a" ;
657+ const std::string b_str = " b" ;
658+ const std::string c_str = " c" ;
659+ {
660+ std::string s = " 0" ;
661+ utils::string::prepend (s, a_str);
662+ utils::string::prepend (s, b_str);
663+ utils::string::prepend (s, c_str);
664+ ASSERT_EQUALS (" cba0" , s);
665+ }
666+ {
667+ std::string s = " 0" ;
668+ utils::string::prepend (s, a_str, b_str, c_str);
669+ ASSERT_EQUALS (" abc0" , s);
670+ }
671+ }
672+ {
673+ std::string s = " 0" ;
674+ utils::string::prepend (s, ' a' );
675+ utils::string::prepend (s, ' b' );
676+ utils::string::prepend (s, ' c' );
677+ ASSERT_EQUALS (" cba0" , s);
678+ }
679+ {
680+ std::string s = " 0" ;
681+ utils::string::prepend (s, ' a' , ' b' , ' c' );
682+ ASSERT_EQUALS (" abc0" , s);
683+ }
684+ {
685+ const std::string a_str = " a" ;
686+ {
687+ std::string s = " 0" ;
688+ utils::string::prepend (s, a_str);
689+ utils::string::prepend (s, ' b' );
690+ utils::string::prepend (s, " c" );
691+ ASSERT_EQUALS (" cba0" , s);
692+ }
693+ {
694+ std::string s = " 0" ;
695+ utils::string::prepend (s, a_str, ' b' , " c" );
696+ ASSERT_EQUALS (" abc0" , s);
697+ }
698+ }
699+ }
578700};
579701
580702REGISTER_TEST (TestUtils)
0 commit comments