1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
13 #include <string_view>
15 #include <cppunit/TestAssert.h>
16 #include <cppunit/TestFixture.h>
17 #include <cppunit/extensions/HelperMacros.h>
19 #include <o3tl/string_view.hxx>
20 #include <rtl/string.hxx>
21 #include <rtl/ustring.hxx>
25 template <> struct assertion_traits
<std::u16string_view
>
27 static bool equal(std::u16string_view x
, std::u16string_view y
) { return x
== y
; }
29 static std::string
toString(std::u16string_view x
)
31 return OUStringToOString(x
, RTL_TEXTENCODING_UTF8
).getStr();
38 OString
ostringEmpty() { return {}; } // avoid loplugin:stringview
39 OString
ostringDoof() { return "doof"; } // avoid loplugin:stringview
40 OString
ostringFoo() { return "foo"; } // avoid loplugin:stringview
41 OString
ostringFoobars() { return "foobars"; } // avoid loplugin:stringview
42 OString
ostringFood() { return "food"; } // avoid loplugin:stringview
43 OString
ostringOof() { return "oof"; } // avoid loplugin:stringview
44 OString
ostringSraboof() { return "sraboof"; } // avoid loplugin:stringview
45 OUString
oustringEmpty() { return {}; } // avoid loplugin:stringview
46 OUString
oustringDoof() { return "doof"; } // avoid loplugin:stringview
47 OUString
oustringFoo() { return "foo"; } // avoid loplugin:stringview
48 OUString
oustringFoobars() { return "foobars"; } // avoid loplugin:stringview
49 OUString
oustringFood() { return "food"; } // avoid loplugin:stringview
50 OUString
oustringOof() { return "oof"; } // avoid loplugin:stringview
51 OUString
oustringSraboof() { return "sraboof"; } // avoid loplugin:stringview
53 class Test
: public CppUnit::TestFixture
56 CPPUNIT_TEST_SUITE(Test
);
57 CPPUNIT_TEST(testStartsWith
);
58 CPPUNIT_TEST(testStartsWithRest
);
59 CPPUNIT_TEST(testEndsWith
);
60 CPPUNIT_TEST(testEndsWithRest
);
61 CPPUNIT_TEST_SUITE_END();
65 using namespace std::string_view_literals
;
66 CPPUNIT_ASSERT(o3tl::starts_with(""sv
, ""sv
));
67 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, "foo"sv
));
68 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ""sv
));
69 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, "foo"sv
));
70 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "food"sv
));
71 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "foobars"sv
));
72 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, 'f'));
73 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, 'f'));
74 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, 'g'));
75 CPPUNIT_ASSERT(o3tl::starts_with(""sv
, ""));
76 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, "foo"));
77 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ""));
78 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, "foo"));
79 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "food"));
80 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "foobars"));
81 CPPUNIT_ASSERT(o3tl::starts_with(""sv
, ostringEmpty()));
82 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, ostringFoo()));
83 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ostringEmpty()));
84 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ostringFoo()));
85 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, ostringFood()));
86 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, ostringFoobars()));
87 CPPUNIT_ASSERT(o3tl::starts_with(u
""sv
, u
""sv
));
88 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, u
"foo"sv
));
89 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
""sv
));
90 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
"foo"sv
));
91 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"food"sv
));
92 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"foobars"sv
));
93 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, u
'f'));
94 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
'f'));
95 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
'g'));
96 CPPUNIT_ASSERT(o3tl::starts_with(u
""sv
, u
""));
97 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, u
"foo"));
98 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
""));
99 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
"foo"));
100 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"food"));
101 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"foobars"));
102 CPPUNIT_ASSERT(o3tl::starts_with(u
""sv
, oustringEmpty()));
103 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, oustringFoo()));
104 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, oustringEmpty()));
105 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, oustringFoo()));
106 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, oustringFood()));
107 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, oustringFoobars()));
110 void testStartsWithRest()
112 using namespace std::string_view_literals
;
114 std::string_view rest
;
115 CPPUNIT_ASSERT(o3tl::starts_with(""sv
, ""sv
, &rest
));
116 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
119 std::string_view rest
;
120 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, "foo"sv
, &rest
));
121 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
124 std::string_view rest
;
125 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ""sv
, &rest
));
126 CPPUNIT_ASSERT_EQUAL("foobar"sv
, rest
);
129 std::string_view rest
;
130 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, "foo"sv
, &rest
));
131 CPPUNIT_ASSERT_EQUAL("bar"sv
, rest
);
134 std::string_view rest
;
135 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "food"sv
, &rest
));
136 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
139 std::string_view rest
;
140 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "foobars"sv
, &rest
));
141 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
144 std::string_view rest
;
145 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, 'f', &rest
));
146 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
149 std::string_view rest
;
150 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, 'f', &rest
));
151 CPPUNIT_ASSERT_EQUAL("oobar"sv
, rest
);
154 std::string_view rest
;
155 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, 'g', &rest
));
156 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
159 std::string_view rest
;
160 CPPUNIT_ASSERT(o3tl::starts_with(""sv
, "", &rest
));
161 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
164 std::string_view rest
;
165 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, "foo", &rest
));
166 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
169 std::string_view rest
;
170 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, "", &rest
));
171 CPPUNIT_ASSERT_EQUAL("foobar"sv
, rest
);
174 std::string_view rest
;
175 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, "foo", &rest
));
176 CPPUNIT_ASSERT_EQUAL("bar"sv
, rest
);
179 std::string_view rest
;
180 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "food", &rest
));
181 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
184 std::string_view rest
;
185 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, "foobars", &rest
));
186 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
189 std::string_view rest
;
190 CPPUNIT_ASSERT(o3tl::starts_with(""sv
, ostringEmpty(), &rest
));
191 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
194 std::string_view rest
;
195 CPPUNIT_ASSERT(!o3tl::starts_with(""sv
, ostringFoo(), &rest
));
196 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
199 std::string_view rest
;
200 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ostringEmpty(), &rest
));
201 CPPUNIT_ASSERT_EQUAL("foobar"sv
, rest
);
204 std::string_view rest
;
205 CPPUNIT_ASSERT(o3tl::starts_with("foobar"sv
, ostringFoo(), &rest
));
206 CPPUNIT_ASSERT_EQUAL("bar"sv
, rest
);
209 std::string_view rest
;
210 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, ostringFood(), &rest
));
211 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
214 std::string_view rest
;
215 CPPUNIT_ASSERT(!o3tl::starts_with("foobar"sv
, ostringFoobars(), &rest
));
216 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
219 std::u16string_view rest
;
220 CPPUNIT_ASSERT(o3tl::starts_with(u
""sv
, u
""sv
, &rest
));
221 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
224 std::u16string_view rest
;
225 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, u
"foo"sv
, &rest
));
226 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
229 std::u16string_view rest
;
230 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
""sv
, &rest
));
231 CPPUNIT_ASSERT_EQUAL(u
"foobar"sv
, rest
);
234 std::u16string_view rest
;
235 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
"foo"sv
, &rest
));
236 CPPUNIT_ASSERT_EQUAL(u
"bar"sv
, rest
);
239 std::u16string_view rest
;
240 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"food"sv
, &rest
));
241 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
244 std::u16string_view rest
;
245 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"foobars"sv
, &rest
));
246 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
249 std::u16string_view rest
;
250 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, u
'f', &rest
));
251 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
254 std::u16string_view rest
;
255 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
'f', &rest
));
256 CPPUNIT_ASSERT_EQUAL(u
"oobar"sv
, rest
);
259 std::u16string_view rest
;
260 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
'g', &rest
));
261 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
264 std::u16string_view rest
;
265 CPPUNIT_ASSERT(o3tl::starts_with(u
""sv
, u
"", &rest
));
266 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
269 std::u16string_view rest
;
270 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, u
"foo", &rest
));
271 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
274 std::u16string_view rest
;
275 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
"", &rest
));
276 CPPUNIT_ASSERT_EQUAL(u
"foobar"sv
, rest
);
279 std::u16string_view rest
;
280 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, u
"foo", &rest
));
281 CPPUNIT_ASSERT_EQUAL(u
"bar"sv
, rest
);
284 std::u16string_view rest
;
285 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"food", &rest
));
286 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
289 std::u16string_view rest
;
290 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, u
"foobars", &rest
));
291 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
294 std::u16string_view rest
;
295 CPPUNIT_ASSERT(o3tl::starts_with(u
""sv
, oustringEmpty(), &rest
));
296 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
299 std::u16string_view rest
;
300 CPPUNIT_ASSERT(!o3tl::starts_with(u
""sv
, oustringFoo(), &rest
));
301 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
304 std::u16string_view rest
;
305 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, oustringEmpty(), &rest
));
306 CPPUNIT_ASSERT_EQUAL(u
"foobar"sv
, rest
);
309 std::u16string_view rest
;
310 CPPUNIT_ASSERT(o3tl::starts_with(u
"foobar"sv
, oustringFoo(), &rest
));
311 CPPUNIT_ASSERT_EQUAL(u
"bar"sv
, rest
);
314 std::u16string_view rest
;
315 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, oustringFood(), &rest
));
316 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
319 std::u16string_view rest
;
320 CPPUNIT_ASSERT(!o3tl::starts_with(u
"foobar"sv
, oustringFoobars(), &rest
));
321 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
327 using namespace std::string_view_literals
;
328 CPPUNIT_ASSERT(o3tl::ends_with(""sv
, ""sv
));
329 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, "oof"sv
));
330 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ""sv
));
331 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, "oof"sv
));
332 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "doof"sv
));
333 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "sraboof"sv
));
334 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, 'f'));
335 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, 'f'));
336 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, 'g'));
337 CPPUNIT_ASSERT(o3tl::ends_with(""sv
, ""));
338 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, "oof"));
339 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ""));
340 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, "oof"));
341 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "doof"));
342 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "sraboof"));
343 CPPUNIT_ASSERT(o3tl::ends_with(""sv
, ostringEmpty()));
344 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, ostringOof()));
345 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ostringEmpty()));
346 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ostringOof()));
347 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, ostringDoof()));
348 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, ostringSraboof()));
349 CPPUNIT_ASSERT(o3tl::ends_with(u
""sv
, u
""sv
));
350 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, u
"oof"sv
));
351 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
""sv
));
352 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
"oof"sv
));
353 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"doof"sv
));
354 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"sraboof"sv
));
355 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, u
'f'));
356 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
'f'));
357 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
'g'));
358 CPPUNIT_ASSERT(o3tl::ends_with(u
""sv
, u
""));
359 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, u
"oof"));
360 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
""));
361 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
"oof"));
362 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"doof"));
363 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"sraboof"));
364 CPPUNIT_ASSERT(o3tl::ends_with(u
""sv
, oustringEmpty()));
365 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, oustringOof()));
366 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, oustringEmpty()));
367 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, oustringOof()));
368 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, oustringDoof()));
369 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, oustringSraboof()));
372 void testEndsWithRest()
374 using namespace std::string_view_literals
;
376 std::string_view rest
;
377 CPPUNIT_ASSERT(o3tl::ends_with(""sv
, ""sv
, &rest
));
378 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
381 std::string_view rest
;
382 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, "oof"sv
, &rest
));
383 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
386 std::string_view rest
;
387 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ""sv
, &rest
));
388 CPPUNIT_ASSERT_EQUAL("raboof"sv
, rest
);
391 std::string_view rest
;
392 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, "oof"sv
, &rest
));
393 CPPUNIT_ASSERT_EQUAL("rab"sv
, rest
);
396 std::string_view rest
;
397 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "doof"sv
, &rest
));
398 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
401 std::string_view rest
;
402 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "sraboof"sv
, &rest
));
403 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
406 std::string_view rest
;
407 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, 'f', &rest
));
408 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
411 std::string_view rest
;
412 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, 'f', &rest
));
413 CPPUNIT_ASSERT_EQUAL("raboo"sv
, rest
);
416 std::string_view rest
;
417 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, 'g', &rest
));
418 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
421 std::string_view rest
;
422 CPPUNIT_ASSERT(o3tl::ends_with(""sv
, "", &rest
));
423 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
426 std::string_view rest
;
427 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, "oof", &rest
));
428 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
431 std::string_view rest
;
432 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, "", &rest
));
433 CPPUNIT_ASSERT_EQUAL("raboof"sv
, rest
);
436 std::string_view rest
;
437 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, "oof", &rest
));
438 CPPUNIT_ASSERT_EQUAL("rab"sv
, rest
);
441 std::string_view rest
;
442 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "doof", &rest
));
443 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
446 std::string_view rest
;
447 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, "sraboof", &rest
));
448 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
451 std::string_view rest
;
452 CPPUNIT_ASSERT(o3tl::ends_with(""sv
, ostringEmpty(), &rest
));
453 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
456 std::string_view rest
;
457 CPPUNIT_ASSERT(!o3tl::ends_with(""sv
, ostringOof(), &rest
));
458 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
461 std::string_view rest
;
462 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ostringEmpty(), &rest
));
463 CPPUNIT_ASSERT_EQUAL("raboof"sv
, rest
);
466 std::string_view rest
;
467 CPPUNIT_ASSERT(o3tl::ends_with("raboof"sv
, ostringOof(), &rest
));
468 CPPUNIT_ASSERT_EQUAL("rab"sv
, rest
);
471 std::string_view rest
;
472 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, ostringDoof(), &rest
));
473 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
476 std::string_view rest
;
477 CPPUNIT_ASSERT(!o3tl::ends_with("raboof"sv
, ostringSraboof(), &rest
));
478 CPPUNIT_ASSERT_EQUAL(""sv
, rest
);
481 std::u16string_view rest
;
482 CPPUNIT_ASSERT(o3tl::ends_with(u
""sv
, u
""sv
, &rest
));
483 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
486 std::u16string_view rest
;
487 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, u
"oof"sv
, &rest
));
488 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
491 std::u16string_view rest
;
492 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
""sv
, &rest
));
493 CPPUNIT_ASSERT_EQUAL(u
"raboof"sv
, rest
);
496 std::u16string_view rest
;
497 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
"oof"sv
, &rest
));
498 CPPUNIT_ASSERT_EQUAL(u
"rab"sv
, rest
);
501 std::u16string_view rest
;
502 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"doof"sv
, &rest
));
503 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
506 std::u16string_view rest
;
507 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"sraboof"sv
, &rest
));
508 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
511 std::u16string_view rest
;
512 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, u
'f', &rest
));
513 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
516 std::u16string_view rest
;
517 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
'f', &rest
));
518 CPPUNIT_ASSERT_EQUAL(u
"raboo"sv
, rest
);
521 std::u16string_view rest
;
522 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
'g', &rest
));
523 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
526 std::u16string_view rest
;
527 CPPUNIT_ASSERT(o3tl::ends_with(u
""sv
, u
"", &rest
));
528 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
531 std::u16string_view rest
;
532 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, u
"oof", &rest
));
533 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
536 std::u16string_view rest
;
537 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
"", &rest
));
538 CPPUNIT_ASSERT_EQUAL(u
"raboof"sv
, rest
);
541 std::u16string_view rest
;
542 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, u
"oof", &rest
));
543 CPPUNIT_ASSERT_EQUAL(u
"rab"sv
, rest
);
546 std::u16string_view rest
;
547 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"doof", &rest
));
548 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
551 std::u16string_view rest
;
552 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, u
"sraboof", &rest
));
553 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
556 std::u16string_view rest
;
557 CPPUNIT_ASSERT(o3tl::ends_with(u
""sv
, oustringEmpty(), &rest
));
558 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
561 std::u16string_view rest
;
562 CPPUNIT_ASSERT(!o3tl::ends_with(u
""sv
, oustringOof(), &rest
));
563 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
566 std::u16string_view rest
;
567 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, oustringEmpty(), &rest
));
568 CPPUNIT_ASSERT_EQUAL(u
"raboof"sv
, rest
);
571 std::u16string_view rest
;
572 CPPUNIT_ASSERT(o3tl::ends_with(u
"raboof"sv
, oustringOof(), &rest
));
573 CPPUNIT_ASSERT_EQUAL(u
"rab"sv
, rest
);
576 std::u16string_view rest
;
577 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, oustringDoof(), &rest
));
578 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
581 std::u16string_view rest
;
582 CPPUNIT_ASSERT(!o3tl::ends_with(u
"raboof"sv
, oustringSraboof(), &rest
));
583 CPPUNIT_ASSERT_EQUAL(u
""sv
, rest
);
588 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
591 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */