1 //===----------------------------------------------------------------------===// 2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 3 // See https://llvm.org/LICENSE.txt for license information. 4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 // 6 //===----------------------------------------------------------------------===// 7 8 // UNSUPPORTED: c++03, c++11, c++14, c++17 9 // UNSUPPORTED: libcpp-no-concepts 10 // UNSUPPORTED: libcpp-has-no-incomplete-format 11 12 // <format> 13 14 // constexpr void advance_to(const_iterator it); 15 16 #include <format> 17 18 #include <cassert> 19 #include <string_view> 20 21 #include "test_macros.h" 22 23 template <class CharT> test(const CharT * fmt)24constexpr void test(const CharT* fmt) { 25 { 26 std::basic_format_parse_context<CharT> context(fmt); 27 28 context.advance_to(context.begin() + 1); 29 assert(context.begin() == &fmt[1]); 30 31 context.advance_to(context.begin() + 1); 32 assert(context.begin() == &fmt[2]); 33 34 context.advance_to(context.begin() + 1); 35 assert(context.begin() == context.end()); 36 } 37 { 38 std::basic_string_view view{fmt}; 39 std::basic_format_parse_context context(view); 40 41 context.advance_to(context.begin() + 1); 42 assert(context.begin() == view.begin() + 1); 43 44 context.advance_to(context.begin() + 1); 45 assert(context.begin() == view.begin() + 2); 46 47 context.advance_to(context.begin() + 1); 48 assert(context.begin() == context.end()); 49 } 50 } 51 test()52constexpr bool test() { 53 test("abc"); 54 test(L"abc"); 55 #ifndef _LIBCPP_HAS_NO_CHAR8_T 56 test(u8"abc"); 57 #endif 58 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 59 test(u"abc"); 60 test(U"abc"); 61 #endif 62 63 return true; 64 } 65 main(int,char **)66int main(int, char**) { 67 test(); 68 static_assert(test()); 69 70 return 0; 71 } 72