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 //===----------------------------------------------------------------------===//
12 // constexpr size_type find_last_of(charT c, size_type pos = npos) const;
14 #include <experimental/string_view>
17 #include "test_macros.h"
18 #include "constexpr_char_traits.hpp"
22 test(const S& s, typename S::value_type c, typename S::size_type pos,
23 typename S::size_type x)
25 assert(s.find_last_of(c, pos) == x);
27 assert(x <= pos && x < s.size());
32 test(const S& s, typename S::value_type c, typename S::size_type x)
34 assert(s.find_last_of(c) == x);
42 typedef std::experimental::string_view S;
43 test(S(""), 'm', 0, S::npos);
44 test(S(""), 'm', 1, S::npos);
45 test(S("kitcj"), 'm', 0, S::npos);
46 test(S("qkamf"), 'm', 1, S::npos);
47 test(S("nhmko"), 'm', 2, 2);
48 test(S("tpsaf"), 'm', 4, S::npos);
49 test(S("lahfb"), 'm', 5, S::npos);
50 test(S("irkhs"), 'm', 6, S::npos);
51 test(S("gmfhdaipsr"), 'm', 0, S::npos);
52 test(S("kantesmpgj"), 'm', 1, S::npos);
53 test(S("odaftiegpm"), 'm', 5, S::npos);
54 test(S("oknlrstdpi"), 'm', 9, S::npos);
55 test(S("eolhfgpjqk"), 'm', 10, S::npos);
56 test(S("pcdrofikas"), 'm', 11, S::npos);
57 test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
58 test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
59 test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
60 test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
61 test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
62 test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
64 test(S(""), 'm', S::npos);
65 test(S("csope"), 'm', S::npos);
66 test(S("gfsmthlkon"), 'm', 3);
67 test(S("laenfsbridchgotmkqpj"), 'm', 15);
72 typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
74 constexpr SV sv2 { "abcde", 5 };
76 static_assert (sv1.find_last_of( 'i', 0 ) == SV::npos, "" );
77 static_assert (sv1.find_last_of( 'i', 1 ) == SV::npos, "" );
78 static_assert (sv2.find_last_of( 'a', 0 ) == 0, "" );
79 static_assert (sv2.find_last_of( 'a', 1 ) == 0, "" );
80 static_assert (sv2.find_last_of( 'e', 5 ) == 4, "" );