1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 // void remove_prefix(size_type _n)
15 #include <experimental/string_view>
19 #include "test_macros.h"
21 template<typename CharT>
22 void test ( const CharT *s, size_t len ) {
23 typedef std::experimental::basic_string_view<CharT> SV;
26 assert ( sv1.size() == len );
27 assert ( sv1.data() == s );
30 sv1.remove_prefix ( 1 );
31 assert ( sv1.size() == (len - 1));
32 assert ( sv1.data() == (s + 1));
33 sv1.remove_prefix ( len - 1 );
36 assert ( sv1.size() == 0 );
37 sv1.remove_prefix ( 0 );
38 assert ( sv1.size() == 0 );
43 constexpr size_t test_ce ( size_t n, size_t k ) {
44 typedef std::experimental::basic_string_view<char> SV;
45 SV sv1{ "ABCDEFGHIJKL", n };
46 sv1.remove_prefix ( k );
60 #if TEST_STD_VER >= 11
72 static_assert ( test_ce ( 5, 0 ) == 5, "" );
73 static_assert ( test_ce ( 5, 1 ) == 4, "" );
74 static_assert ( test_ce ( 5, 5 ) == 0, "" );
75 static_assert ( test_ce ( 9, 3 ) == 6, "" );