@@ -45,6 +45,9 @@ class TestUtils : public TestFixture {
4545 TEST_CASE (as_const);
4646 TEST_CASE (memoize);
4747 TEST_CASE (endsWith);
48+ TEST_CASE (stringConcat);
49+ TEST_CASE (stringCreate);
50+ TEST_CASE (stringPrepend);
4851 }
4952
5053 void isValidGlobPattern () const {
@@ -575,6 +578,154 @@ class TestUtils : public TestFixture {
575578 ASSERT (!::endsWith (" tes" , " test" ));
576579 ASSERT (!::endsWith (" 2test" , " 2" ));
577580 }
581+
582+ void stringConcat () const
583+ {
584+ {
585+ std::string s = " 0" ;
586+ utils::string::concat (s, " a" );
587+ utils::string::concat (s, " b" );
588+ utils::string::concat (s, " c" );
589+ ASSERT_EQUALS (" 0abc" , s);
590+ }
591+ {
592+ std::string s = " 0" ;
593+ utils::string::concat (s, " a" , " b" , " c" );
594+ ASSERT_EQUALS (" 0abc" , s);
595+ }
596+ {
597+ const std::string a_str = " a" ;
598+ const std::string b_str = " b" ;
599+ const std::string c_str = " c" ;
600+ {
601+ std::string s = " 0" ;
602+ utils::string::concat (s, a_str);
603+ utils::string::concat (s, b_str);
604+ utils::string::concat (s, c_str);
605+ ASSERT_EQUALS (" 0abc" , s);
606+ }
607+ {
608+ std::string s = " 0" ;
609+ utils::string::concat (s, a_str, b_str, c_str);
610+ ASSERT_EQUALS (" 0abc" , s);
611+ }
612+ }
613+ {
614+ std::string s = " 0" ;
615+ utils::string::concat (s, ' a' );
616+ utils::string::concat (s, ' b' );
617+ utils::string::concat (s, ' c' );
618+ ASSERT_EQUALS (" 0abc" , s);
619+ }
620+ {
621+ std::string s = " 0" ;
622+ utils::string::concat (s, ' a' , ' b' , ' c' );
623+ ASSERT_EQUALS (" 0abc" , s);
624+ }
625+ {
626+ const std::string a_str = " a" ;
627+ {
628+ std::string s = " 0" ;
629+ utils::string::concat (s, a_str);
630+ utils::string::concat (s, ' b' );
631+ utils::string::concat (s, " c" );
632+ ASSERT_EQUALS (" 0abc" , s);
633+ }
634+ {
635+ std::string s = " 0" ;
636+ utils::string::concat (s, a_str, ' b' , " c" );
637+ ASSERT_EQUALS (" 0abc" , s);
638+ }
639+ }
640+ }
641+
642+ void stringCreate () const
643+ {
644+ {
645+ std::string s = utils::string::create (" a" , " b" , " c" );
646+ ASSERT_EQUALS (" abc" , s);
647+ }
648+ {
649+ const std::string a_str = " a" ;
650+ const std::string b_str = " b" ;
651+ const std::string c_str = " c" ;
652+ {
653+ std::string s = utils::string::create (a_str, b_str, c_str);
654+ ASSERT_EQUALS (" abc" , s);
655+ }
656+ }
657+ {
658+ std::string s = utils::string::create (' a' , ' b' , ' c' );
659+ ASSERT_EQUALS (" abc" , s);
660+ }
661+ {
662+ const std::string a_str = " a" ;
663+ {
664+ std::string s = utils::string::create (a_str, ' b' , " c" );
665+ ASSERT_EQUALS (" abc" , s);
666+ }
667+ }
668+ }
669+
670+ void stringPrepend () const
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+ const std::string b_str = " b" ;
687+ const std::string c_str = " c" ;
688+ {
689+ std::string s = " 0" ;
690+ utils::string::prepend (s, a_str);
691+ utils::string::prepend (s, b_str);
692+ utils::string::prepend (s, c_str);
693+ ASSERT_EQUALS (" cba0" , s);
694+ }
695+ {
696+ std::string s = " 0" ;
697+ utils::string::prepend (s, a_str, b_str, c_str);
698+ ASSERT_EQUALS (" abc0" , s);
699+ }
700+ }
701+ {
702+ std::string s = " 0" ;
703+ utils::string::prepend (s, ' a' );
704+ utils::string::prepend (s, ' b' );
705+ utils::string::prepend (s, ' c' );
706+ ASSERT_EQUALS (" cba0" , s);
707+ }
708+ {
709+ std::string s = " 0" ;
710+ utils::string::prepend (s, ' a' , ' b' , ' c' );
711+ ASSERT_EQUALS (" abc0" , s);
712+ }
713+ {
714+ const std::string a_str = " a" ;
715+ {
716+ std::string s = " 0" ;
717+ utils::string::prepend (s, a_str);
718+ utils::string::prepend (s, ' b' );
719+ utils::string::prepend (s, " c" );
720+ ASSERT_EQUALS (" cba0" , s);
721+ }
722+ {
723+ std::string s = " 0" ;
724+ utils::string::prepend (s, a_str, ' b' , " c" );
725+ ASSERT_EQUALS (" abc0" , s);
726+ }
727+ }
728+ }
578729};
579730
580731REGISTER_TEST (TestUtils)
0 commit comments