| 1 | // { dg-do run { target c++20 } } |
| 2 | |
| 3 | // Copyright (C) 2018-2025 Free Software Foundation, Inc. |
| 4 | // |
| 5 | // This file is part of the GNU ISO C++ Library. This library is free |
| 6 | // software; you can redistribute it and/or modify it under the |
| 7 | // terms of the GNU General Public License as published by the |
| 8 | // Free Software Foundation; either version 3, or (at your option) |
| 9 | // any later version. |
| 10 | |
| 11 | // This library is distributed in the hope that it will be useful, |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | // GNU General Public License for more details. |
| 15 | |
| 16 | // You should have received a copy of the GNU General Public License along |
| 17 | // with this library; see the file COPYING3. If not see |
| 18 | // <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | // basic_string begins_with |
| 21 | |
| 22 | #include <testsuite_string.h> |
| 23 | #include <testsuite_hooks.h> |
| 24 | |
| 25 | void |
| 26 | test01() |
| 27 | { |
| 28 | const wchar_t cstr_dir[] = L"slugs/"; |
| 29 | const std::wstring_view sv_dir(L"slugs/"); |
| 30 | const wchar_t cstr_dir2[] = L"worms/"; |
| 31 | const std::wstring_view sv_dir2(L"worms/"); |
| 32 | |
| 33 | const __gnu_test::wstring s_test(L"slugs/slimy.jpg"); |
| 34 | |
| 35 | const auto cstr_in_slugs = s_test.starts_with(cstr_dir); |
| 36 | VERIFY( cstr_in_slugs ); |
| 37 | const auto sv_in_slugs = s_test.starts_with(sv_dir); |
| 38 | VERIFY( sv_in_slugs ); |
| 39 | const auto char_s = s_test.starts_with(L's'); |
| 40 | VERIFY( char_s ); |
| 41 | |
| 42 | const auto cstr_in_worms = s_test.starts_with(cstr_dir2); |
| 43 | VERIFY( !cstr_in_worms ); |
| 44 | const auto sv_in_worms = s_test.starts_with(sv_dir2); |
| 45 | VERIFY( !sv_in_worms ); |
| 46 | const auto char_w = s_test.starts_with(L'w'); |
| 47 | VERIFY( !char_w ); |
| 48 | } |
| 49 | |
| 50 | int |
| 51 | main() |
| 52 | { |
| 53 | test01(); |
| 54 | return 0; |
| 55 | } |