cxx/test/strings/basic.string/string.ops/string::find.last.not.of/char_size.pass.cpp
Howard Hinnant bc8d3f97eb libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 19:42:16 +00:00

66 lines
1.8 KiB
C++

//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type find_last_not_of(charT c, size_type pos = npos) const;
#include <string>
#include <cassert>
template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_last_not_of(c, pos) == x);
if (x != S::npos)
assert(x <= pos && x < s.size());
}
template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type x)
{
assert(s.find_last_not_of(c) == x);
if (x != S::npos)
assert(x < s.size());
}
typedef std::string S;
int main()
{
test(S(""), 'i', 0, S::npos);
test(S(""), 'i', 1, S::npos);
test(S("kitcj"), 'i', 0, 0);
test(S("qkamf"), 'i', 1, 1);
test(S("nhmko"), 'i', 2, 2);
test(S("tpsaf"), 'i', 4, 4);
test(S("lahfb"), 'i', 5, 4);
test(S("irkhs"), 'i', 6, 4);
test(S("gmfhdaipsr"), 'i', 0, 0);
test(S("kantesmpgj"), 'i', 1, 1);
test(S("odaftiegpm"), 'i', 5, 4);
test(S("oknlrstdpi"), 'i', 9, 8);
test(S("eolhfgpjqk"), 'i', 10, 9);
test(S("pcdrofikas"), 'i', 11, 9);
test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
test(S(""), 'i', S::npos);
test(S("csope"), 'i', 4);
test(S("gfsmthlkon"), 'i', 9);
test(S("laenfsbridchgotmkqpj"), 'i', 19);
}