@@ -112,3 +112,62 @@ TEST_CASE("find_by_name()", "[NoDB]")
112112 REQUIRE (util::find_by_name (t, " baz" ) == &t[2 ]);
113113 REQUIRE (util::find_by_name (t, " nothing" ) == nullptr );
114114}
115+
116+ TEST_CASE (" Use string_joiner_t with delim only without items" , " [NoDB]" )
117+ {
118+ util::string_joiner_t joiner{' ,' };
119+ REQUIRE (joiner ().empty ());
120+ }
121+
122+ TEST_CASE (" Use string_joiner_t with all params without items" , " [NoDB]" )
123+ {
124+ util::string_joiner_t joiner{' ,' , ' "' , ' (' , ' )' };
125+ REQUIRE (joiner ().empty ());
126+ }
127+
128+ TEST_CASE (" Use string_joiner_t without quote char" , " [NoDB]" )
129+ {
130+ util::string_joiner_t joiner{' ,' , ' \0 ' , ' (' , ' )' };
131+ joiner.add (" foo" );
132+ joiner.add (" bar" );
133+ REQUIRE (joiner () == " (foo,bar)" );
134+ }
135+
136+ TEST_CASE (" string_joiner_t without before/after" , " [NoDB]" )
137+ {
138+ util::string_joiner_t joiner{' ,' };
139+ joiner.add (" xxx" );
140+ joiner.add (" yyy" );
141+ REQUIRE (joiner () == " xxx,yyy" );
142+ }
143+
144+ TEST_CASE (" string_joiner_t with single single-char item" , " [NoDB]" )
145+ {
146+ util::string_joiner_t joiner{' ,' };
147+ joiner.add (" x" );
148+ REQUIRE (joiner () == " x" );
149+ }
150+
151+ TEST_CASE (" string_joiner_t with single single-char item and wrapper" , " [NoDB]" )
152+ {
153+ util::string_joiner_t joiner{' ,' , ' \0 ' , ' (' , ' )' };
154+ joiner.add (" x" );
155+ REQUIRE (joiner () == " (x)" );
156+ }
157+
158+ TEST_CASE (" join strings" , " [NoDB]" )
159+ {
160+ std::vector<std::string> const t{" abc" , " def" , " " , " ghi" };
161+
162+ REQUIRE (util::join (t, ' ,' ) == " abc,def,,ghi" );
163+ REQUIRE (util::join (t, ' -' , ' #' , ' [' , ' ]' ) == " [#abc#-#def#-##-#ghi#]" );
164+ REQUIRE (util::join (t, ' -' , ' #' , ' [' , ' ]' ) == " [#abc#-#def#-##-#ghi#]" );
165+ }
166+
167+ TEST_CASE (" join strings with empty list" , " [NoDB]" )
168+ {
169+ std::vector<std::string> const t{};
170+
171+ REQUIRE (util::join (t, ' ,' ).empty ());
172+ REQUIRE (util::join (t, ' -' , ' #' , ' [' , ' ]' ).empty ());
173+ }
0 commit comments