1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 12 // size_type find_first_not_of(charT c, size_type pos = 0) const; 13 14 #include <string> 15 #include <cassert> 16 17 #include "min_allocator.h" 18 19 template <class S> 20 void 21 test(const S& s, typename S::value_type c, typename S::size_type pos, 22 typename S::size_type x) 23 { 24 assert(s.find_first_not_of(c, pos) == x); 25 if (x != S::npos) 26 assert(pos <= x && x < s.size()); 27 } 28 29 template <class S> 30 void 31 test(const S& s, typename S::value_type c, typename S::size_type x) 32 { 33 assert(s.find_first_not_of(c) == x); 34 if (x != S::npos) 35 assert(x < s.size()); 36 } 37 38 int main() 39 { 40 { 41 typedef std::string S; 42 test(S(""), 'q', 0, S::npos); 43 test(S(""), 'q', 1, S::npos); 44 test(S("kitcj"), 'q', 0, 0); 45 test(S("qkamf"), 'q', 1, 1); 46 test(S("nhmko"), 'q', 2, 2); 47 test(S("tpsaf"), 'q', 4, 4); 48 test(S("lahfb"), 'q', 5, S::npos); 49 test(S("irkhs"), 'q', 6, S::npos); 50 test(S("gmfhdaipsr"), 'q', 0, 0); 51 test(S("kantesmpgj"), 'q', 1, 1); 52 test(S("odaftiegpm"), 'q', 5, 5); 53 test(S("oknlrstdpi"), 'q', 9, 9); 54 test(S("eolhfgpjqk"), 'q', 10, S::npos); 55 test(S("pcdrofikas"), 'q', 11, S::npos); 56 test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0); 57 test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1); 58 test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10); 59 test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19); 60 test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos); 61 test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos); 62 63 test(S(""), 'q', S::npos); 64 test(S("q"), 'q', S::npos); 65 test(S("qqq"), 'q', S::npos); 66 test(S("csope"), 'q', 0); 67 test(S("gfsmthlkon"), 'q', 0); 68 test(S("laenfsbridchgotmkqpj"), 'q', 0); 69 } 70 #if __cplusplus >= 201103L 71 { 72 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 73 test(S(""), 'q', 0, S::npos); 74 test(S(""), 'q', 1, S::npos); 75 test(S("kitcj"), 'q', 0, 0); 76 test(S("qkamf"), 'q', 1, 1); 77 test(S("nhmko"), 'q', 2, 2); 78 test(S("tpsaf"), 'q', 4, 4); 79 test(S("lahfb"), 'q', 5, S::npos); 80 test(S("irkhs"), 'q', 6, S::npos); 81 test(S("gmfhdaipsr"), 'q', 0, 0); 82 test(S("kantesmpgj"), 'q', 1, 1); 83 test(S("odaftiegpm"), 'q', 5, 5); 84 test(S("oknlrstdpi"), 'q', 9, 9); 85 test(S("eolhfgpjqk"), 'q', 10, S::npos); 86 test(S("pcdrofikas"), 'q', 11, S::npos); 87 test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0); 88 test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1); 89 test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10); 90 test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19); 91 test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos); 92 test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos); 93 94 test(S(""), 'q', S::npos); 95 test(S("q"), 'q', S::npos); 96 test(S("qqq"), 'q', S::npos); 97 test(S("csope"), 'q', 0); 98 test(S("gfsmthlkon"), 'q', 0); 99 test(S("laenfsbridchgotmkqpj"), 'q', 0); 100 } 101 #endif 102 } 103