@@ -137,7 +137,6 @@ FATAL_TEST(sanity_check, empty) {
137137// comparison //
138138// //////////////
139139
140- FATAL_TEST (comparison, equal) {
141140# define TEST_IMPL_COMPARE (r, other ) \
142141 do { \
143142 FATAL_EXPECT_EQ (0 , r.compare (other)); \
@@ -161,118 +160,144 @@ FATAL_TEST(comparison, equal) {
161160 FATAL_EXPECT_TRUE (other >= r); \
162161 } while (false )
163162
163+ FATAL_TEST (comparison, equal) {
164164# define TEST_IMPL (...) \
165165 do { \
166166 auto const str = to_string (__VA_ARGS__); \
167+ rope<> r1 (__VA_ARGS__); \
168+ auto cr1 = r1.mimic (); \
169+ rope<> r2 (__VA_ARGS__); \
170+ auto cr2 = r2.mimic (); \
171+ string_view ref (str); \
172+ auto cstr = str.c_str (); \
173+ std::vector<char > v (str.cbegin (), str.cend ()); \
174+ v.push_back (' \0 ' ); \
175+ auto c = v.data (); \
176+ std::string s (str); \
167177 \
168- { \
169- rope<> r1 (__VA_ARGS__); \
170- auto cr1 = r1.mimic (); \
171- rope<> r2 (__VA_ARGS__); \
172- auto cr2 = r2.mimic (); \
173- string_view ref (str); \
174- auto cstr = str.c_str (); \
175- std::vector<char > v (str.cbegin (), str.cend ()); \
176- v.push_back (' \0 ' ); \
177- auto c = v.data (); \
178- std::string s (str); \
179- \
180- TEST_IMPL_COMPARE (r1, r1); \
181- TEST_IMPL_COMPARE (cr1, r1); \
182- TEST_IMPL_COMPARE (r1, cr1); \
183- TEST_IMPL_COMPARE (r1, r2); \
184- TEST_IMPL_COMPARE (cr1, r2); \
185- TEST_IMPL_COMPARE (r1, cr2); \
186- TEST_IMPL_COMPARE (r1, ref); \
187- TEST_IMPL_COMPARE (r1, cstr); \
188- TEST_IMPL_COMPARE (r1, c); \
189- TEST_IMPL_COMPARE (r1, s); \
190- TEST_IMPL_COMPARE (cr1, ref); \
191- TEST_IMPL_COMPARE (cr1, cstr); \
192- TEST_IMPL_COMPARE (cr1, c); \
193- TEST_IMPL_COMPARE (cr1, s); \
194- } \
195- { \
196- rope<> const r1 (__VA_ARGS__); \
197- auto const cr1 = r1.mimic (); \
198- rope<> const r2 (__VA_ARGS__); \
199- auto const cr2 = r2.mimic (); \
200- string_view const ref (str); \
201- auto const cstr = str.c_str (); \
202- std::vector<char > v (str.cbegin (), str.cend ()); \
203- v.push_back (' \0 ' ); \
204- auto const c = v.data (); \
205- std::string const s (str); \
206- \
207- TEST_IMPL_COMPARE (r1, r1); \
208- TEST_IMPL_COMPARE (cr1, r1); \
209- TEST_IMPL_COMPARE (r1, cr1); \
210- TEST_IMPL_COMPARE (r1, r2); \
211- TEST_IMPL_COMPARE (cr1, r2); \
212- TEST_IMPL_COMPARE (r1, cr2); \
213- TEST_IMPL_COMPARE (r1, ref); \
214- TEST_IMPL_COMPARE (r1, cstr); \
215- TEST_IMPL_COMPARE (r1, c); \
216- TEST_IMPL_COMPARE (r1, s); \
217- TEST_IMPL_COMPARE (cr1, ref); \
218- TEST_IMPL_COMPARE (cr1, cstr); \
219- TEST_IMPL_COMPARE (cr1, c); \
220- TEST_IMPL_COMPARE (cr1, s); \
221- } \
222- { \
223- rope<> r1 (__VA_ARGS__); \
224- auto cr1 = r1.mimic (); \
225- rope<> r2 (__VA_ARGS__); \
226- auto cr2 = r2.mimic (); \
227- string_view ref (str); \
228- auto cstr = str.c_str (); \
229- std::vector<char > v (str.cbegin (), str.cend ()); \
230- v.push_back (' \0 ' ); \
231- auto c = v.data (); \
232- std::string s (str); \
233- \
234- TEST_IMPL_COMPARE (std::move (r1), std::move (r1)); \
235- TEST_IMPL_COMPARE (std::move (cr1), std::move (r1)); \
236- TEST_IMPL_COMPARE (std::move (r1), std::move (cr1)); \
237- TEST_IMPL_COMPARE (std::move (r1), std::move (r2)); \
238- TEST_IMPL_COMPARE (std::move (cr1), std::move (r2)); \
239- TEST_IMPL_COMPARE (std::move (r1), std::move (cr2)); \
240- TEST_IMPL_COMPARE (std::move (r1), std::move (ref)); \
241- TEST_IMPL_COMPARE (std::move (r1), std::move (cstr)); \
242- TEST_IMPL_COMPARE (std::move (r1), std::move (c)); \
243- TEST_IMPL_COMPARE (std::move (r1), std::move (s)); \
244- TEST_IMPL_COMPARE (std::move (cr1), std::move (ref)); \
245- TEST_IMPL_COMPARE (std::move (cr1), std::move (cstr)); \
246- TEST_IMPL_COMPARE (std::move (cr1), std::move (c)); \
247- TEST_IMPL_COMPARE (std::move (cr1), std::move (s)); \
248- } \
249- { \
250- rope<> r1 (__VA_ARGS__); \
251- auto cr1 = r1.mimic (); \
252- std::vector<char > v (str.cbegin (), str.cend ()); \
253- v.push_back (' \0 ' ); \
254- \
255- TEST_IMPL_COMPARE (r1, rope<>(__VA_ARGS__)); \
256- TEST_IMPL_COMPARE (cr1, rope<>(__VA_ARGS__)); \
257- TEST_IMPL_COMPARE (r1, rope<>(__VA_ARGS__).mimic ()); \
258- TEST_IMPL_COMPARE (cr1, rope<>(__VA_ARGS__).mimic ()); \
259- TEST_IMPL_COMPARE (r1, string_view (str)); \
260- TEST_IMPL_COMPARE (r1, str.c_str ()); \
261- TEST_IMPL_COMPARE (r1, v.data ()); \
262- TEST_IMPL_COMPARE (r1, std::string (str)); \
263- TEST_IMPL_COMPARE (cr1, string_view (str)); \
264- TEST_IMPL_COMPARE (cr1, str.c_str ()); \
265- TEST_IMPL_COMPARE (cr1, v.data ()); \
266- TEST_IMPL_COMPARE (cr1, std::string (str)); \
267- } \
178+ TEST_IMPL_COMPARE (r1, r1); \
179+ TEST_IMPL_COMPARE (cr1, r1); \
180+ TEST_IMPL_COMPARE (r1, cr1); \
181+ TEST_IMPL_COMPARE (r1, r2); \
182+ TEST_IMPL_COMPARE (cr1, r2); \
183+ TEST_IMPL_COMPARE (r1, cr2); \
184+ TEST_IMPL_COMPARE (r1, ref); \
185+ TEST_IMPL_COMPARE (r1, cstr); \
186+ TEST_IMPL_COMPARE (r1, c); \
187+ TEST_IMPL_COMPARE (r1, s); \
188+ TEST_IMPL_COMPARE (cr1, ref); \
189+ TEST_IMPL_COMPARE (cr1, cstr); \
190+ TEST_IMPL_COMPARE (cr1, c); \
191+ TEST_IMPL_COMPARE (cr1, s); \
268192 } while (false )
269193
270194 TEST_IMPL_SINGLE_STRING (TEST_IMPL);
271195
272196# undef TEST_IMPL
273- # undef TEST_IMPL_COMPARE
274197}
275198
199+ FATAL_TEST (comparison, equal_const) {
200+ # define TEST_IMPL (...) \
201+ do { \
202+ auto const str = to_string (__VA_ARGS__); \
203+ rope<> const r1 (__VA_ARGS__); \
204+ auto const cr1 = r1.mimic (); \
205+ rope<> const r2 (__VA_ARGS__); \
206+ auto const cr2 = r2.mimic (); \
207+ string_view const ref (str); \
208+ auto const cstr = str.c_str (); \
209+ std::vector<char > v (str.cbegin (), str.cend ()); \
210+ v.push_back (' \0 ' ); \
211+ auto const c = v.data (); \
212+ std::string const s (str); \
213+ \
214+ TEST_IMPL_COMPARE (r1, r1); \
215+ TEST_IMPL_COMPARE (cr1, r1); \
216+ TEST_IMPL_COMPARE (r1, cr1); \
217+ TEST_IMPL_COMPARE (r1, r2); \
218+ TEST_IMPL_COMPARE (cr1, r2); \
219+ TEST_IMPL_COMPARE (r1, cr2); \
220+ TEST_IMPL_COMPARE (r1, ref); \
221+ TEST_IMPL_COMPARE (r1, cstr); \
222+ TEST_IMPL_COMPARE (r1, c); \
223+ TEST_IMPL_COMPARE (r1, s); \
224+ TEST_IMPL_COMPARE (cr1, ref); \
225+ TEST_IMPL_COMPARE (cr1, cstr); \
226+ TEST_IMPL_COMPARE (cr1, c); \
227+ TEST_IMPL_COMPARE (cr1, s); \
228+ } while (false )
229+
230+ TEST_IMPL_SINGLE_STRING (TEST_IMPL);
231+
232+ # undef TEST_IMPL
233+ }
234+
235+ FATAL_TEST (comparison, equal_move) {
236+ # define TEST_IMPL (...) \
237+ do { \
238+ auto const str = to_string (__VA_ARGS__); \
239+ rope<> r1 (__VA_ARGS__); \
240+ auto cr1 = r1.mimic (); \
241+ rope<> r2 (__VA_ARGS__); \
242+ auto cr2 = r2.mimic (); \
243+ string_view ref (str); \
244+ auto cstr = str.c_str (); \
245+ std::vector<char > v (str.cbegin (), str.cend ()); \
246+ v.push_back (' \0 ' ); \
247+ auto c = v.data (); \
248+ std::string s (str); \
249+ \
250+ TEST_IMPL_COMPARE (std::move (r1), std::move (r1)); \
251+ TEST_IMPL_COMPARE (std::move (cr1), std::move (r1)); \
252+ TEST_IMPL_COMPARE (std::move (r1), std::move (cr1)); \
253+ TEST_IMPL_COMPARE (std::move (r1), std::move (r2)); \
254+ TEST_IMPL_COMPARE (std::move (cr1), std::move (r2)); \
255+ TEST_IMPL_COMPARE (std::move (r1), std::move (cr2)); \
256+ TEST_IMPL_COMPARE (std::move (r1), std::move (ref)); \
257+ TEST_IMPL_COMPARE (std::move (r1), std::move (cstr)); \
258+ TEST_IMPL_COMPARE (std::move (r1), std::move (c)); \
259+ TEST_IMPL_COMPARE (std::move (r1), std::move (s)); \
260+ TEST_IMPL_COMPARE (std::move (cr1), std::move (ref)); \
261+ TEST_IMPL_COMPARE (std::move (cr1), std::move (cstr)); \
262+ TEST_IMPL_COMPARE (std::move (cr1), std::move (c)); \
263+ TEST_IMPL_COMPARE (std::move (cr1), std::move (s)); \
264+ } while (false )
265+
266+ TEST_IMPL_SINGLE_STRING (TEST_IMPL);
267+
268+ # undef TEST_IMPL
269+ }
270+
271+ FATAL_TEST (comparison, equal_other) {
272+ # define TEST_IMPL (...) \
273+ do { \
274+ auto const str = to_string (__VA_ARGS__); \
275+ rope<> r1 (__VA_ARGS__); \
276+ auto cr1 = r1.mimic (); \
277+ std::vector<char > v (str.cbegin (), str.cend ()); \
278+ v.push_back (' \0 ' ); \
279+ \
280+ TEST_IMPL_COMPARE (r1, rope<>(__VA_ARGS__)); \
281+ TEST_IMPL_COMPARE (cr1, rope<>(__VA_ARGS__)); \
282+ TEST_IMPL_COMPARE (r1, rope<>(__VA_ARGS__).mimic ()); \
283+ TEST_IMPL_COMPARE (cr1, rope<>(__VA_ARGS__).mimic ()); \
284+ TEST_IMPL_COMPARE (r1, string_view (str)); \
285+ TEST_IMPL_COMPARE (r1, str.c_str ()); \
286+ TEST_IMPL_COMPARE (r1, v.data ()); \
287+ TEST_IMPL_COMPARE (r1, std::string (str)); \
288+ TEST_IMPL_COMPARE (cr1, string_view (str)); \
289+ TEST_IMPL_COMPARE (cr1, str.c_str ()); \
290+ TEST_IMPL_COMPARE (cr1, v.data ()); \
291+ TEST_IMPL_COMPARE (cr1, std::string (str)); \
292+ } while (false )
293+
294+ TEST_IMPL_SINGLE_STRING (TEST_IMPL);
295+
296+ # undef TEST_IMPL
297+ }
298+
299+ # undef TEST_IMPL_COMPARE
300+
276301FATAL_TEST (comparison, not_equal) {
277302# define TEST_IMPL_COMPARE (r, other, expected_less ) \
278303 do { \
0 commit comments