10b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//===----------------------------------------------------------------------===//
20b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//
30b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//                     The LLVM Compiler Infrastructure
40b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//
50b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow// This file is dual licensed under the MIT and the University of Illinois Open
60b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow// Source Licenses. See LICENSE.TXT for details.
70b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//
80b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//===----------------------------------------------------------------------===//
90b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
100b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow// <string>
110b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
120b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow// size_type find_last_not_of(basic_string_view sv, size_type pos = npos) const;
130b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
140b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow#include <string>
150b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow#include <cassert>
160b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
170b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow#include "min_allocator.h"
180b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
190b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowtemplate <class S, class SV>
200b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowvoid
210b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowtest(const S& s, SV sv, typename S::size_type pos, typename S::size_type x)
220b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow{
230b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    assert(s.find_last_not_of(sv, pos) == x);
240b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    if (x != S::npos)
250b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow        assert(x <= pos && x < s.size());
260b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow}
270b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
280b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowtemplate <class S, class SV>
290b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowvoid
300b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowtest(const S& s, SV sv, typename S::size_type x)
310b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow{
320b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    assert(s.find_last_not_of(sv) == x);
330b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    if (x != S::npos)
340b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow        assert(x < s.size());
350b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow}
360b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
370b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowtemplate <class S, class SV>
380b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowvoid test0()
390b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow{
400b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV(""), 0, S::npos);
410b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("laenf"), 0, S::npos);
420b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("pqlnkmbdjo"), 0, S::npos);
430b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("qkamfogpnljdcshbreti"), 0, S::npos);
440b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV(""), 1, S::npos);
450b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("bjaht"), 1, S::npos);
460b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("hjlcmgpket"), 1, S::npos);
470b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("htaobedqikfplcgjsmrn"), 1, S::npos);
480b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("fodgq"), SV(""), 0, 0);
490b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("qanej"), SV("dfkap"), 0, 0);
500b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("clbao"), SV("ihqrfebgad"), 0, 0);
510b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("mekdn"), SV("ngtjfcalbseiqrphmkdo"), 0, S::npos);
520b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("srdfq"), SV(""), 1, 1);
530b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("oemth"), SV("ikcrq"), 1, 1);
540b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("cdaih"), SV("dmajblfhsg"), 1, 0);
550b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("qohtk"), SV("oqftjhdmkgsblacenirp"), 1, S::npos);
560b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("cshmd"), SV(""), 2, 2);
570b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("lhcdo"), SV("oebqi"), 2, 2);
580b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("qnsoh"), SV("kojhpmbsfe"), 2, 1);
590b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("pkrof"), SV("acbsjqogpltdkhinfrem"), 2, S::npos);
600b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("fmtsp"), SV(""), 4, 4);
610b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("khbpm"), SV("aobjd"), 4, 4);
620b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("pbsji"), SV("pcbahntsje"), 4, 4);
630b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("mprdj"), SV("fhepcrntkoagbmldqijs"), 4, S::npos);
640b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("eqmpa"), SV(""), 5, 4);
650b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("omigs"), SV("kocgb"), 5, 4);
660b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("onmje"), SV("fbslrjiqkm"), 5, 4);
670b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("oqmrj"), SV("jeidpcmalhfnqbgtrsko"), 5, S::npos);
680b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("schfa"), SV(""), 6, 4);
690b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("igdsc"), SV("qngpd"), 6, 4);
700b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("brqgo"), SV("rodhqklgmb"), 6, S::npos);
710b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("tnrph"), SV("thdjgafrlbkoiqcspmne"), 6, S::npos);
720b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("hcjitbfapl"), SV(""), 0, 0);
730b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("daiprenocl"), SV("ashjd"), 0, S::npos);
740b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("litpcfdghe"), SV("mgojkldsqh"), 0, S::npos);
750b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("aidjksrolc"), SV("imqnaghkfrdtlopbjesc"), 0, S::npos);
760b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("qpghtfbaji"), SV(""), 1, 1);
770b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("gfshlcmdjr"), SV("nadkh"), 1, 1);
780b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("nkodajteqp"), SV("ofdrqmkebl"), 1, 0);
790b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("gbmetiprqd"), SV("bdfjqgatlksriohemnpc"), 1, S::npos);
800b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("crnklpmegd"), SV(""), 5, 5);
810b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("jsbtafedoc"), SV("prqgn"), 5, 5);
820b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("qnmodrtkeb"), SV("pejafmnokr"), 5, 4);
830b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("cpebqsfmnj"), SV("odnqkgijrhabfmcestlp"), 5, S::npos);
840b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("lmofqdhpki"), SV(""), 9, 9);
850b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("hnefkqimca"), SV("rtjpa"), 9, 8);
860b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("drtasbgmfp"), SV("ktsrmnqagd"), 9, 9);
870b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("lsaijeqhtr"), SV("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
880b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("elgofjmbrq"), SV(""), 10, 9);
890b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("mjqdgalkpc"), SV("dplqa"), 10, 9);
900b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("kthqnfcerm"), SV("dkacjoptns"), 10, 9);
910b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("dfsjhanorc"), SV("hqfimtrgnbekpdcsjalo"), 10, S::npos);
920b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("eqsgalomhb"), SV(""), 11, 9);
930b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("akiteljmoh"), SV("lofbc"), 11, 9);
940b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("hlbdfreqjo"), SV("astoegbfpn"), 11, 8);
950b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("taqobhlerg"), SV("pdgreqomsncafklhtibj"), 11, S::npos);
960b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("snafbdlghrjkpqtoceim"), SV(""), 0, 0);
970b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("aemtbrgcklhndjisfpoq"), SV("lbtqd"), 0, 0);
980b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("pnracgfkjdiholtbqsem"), SV("tboimldpjh"), 0, S::npos);
990b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("dicfltehbsgrmojnpkaq"), SV("slcerthdaiqjfnobgkpm"), 0, S::npos);
1000b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("jlnkraeodhcspfgbqitm"), SV(""), 1, 1);
1010b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("lhosrngtmfjikbqpcade"), SV("aqibs"), 1, 1);
1020b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("rbtaqjhgkneisldpmfoc"), SV("gtfblmqinc"), 1, 0);
1030b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("gpifsqlrdkbonjtmheca"), SV("mkqpbtdalgniorhfescj"), 1, S::npos);
1040b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("hdpkobnsalmcfijregtq"), SV(""), 10, 10);
1050b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("jtlshdgqaiprkbcoenfm"), SV("pblas"), 10, 9);
1060b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("fkdrbqltsgmcoiphneaj"), SV("arosdhcfme"), 10, 9);
1070b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("crsplifgtqedjohnabmk"), SV("blkhjeogicatqfnpdmsr"), 10, S::npos);
1080b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("niptglfbosehkamrdqcj"), SV(""), 19, 19);
1090b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("copqdhstbingamjfkler"), SV("djkqc"), 19, 19);
1100b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("mrtaefilpdsgocnhqbjk"), SV("lgokshjtpb"), 19, 16);
1110b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("kojatdhlcmigpbfrqnes"), SV("bqjhtkfepimcnsgrlado"), 19, S::npos);
1120b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("eaintpchlqsbdgrkjofm"), SV(""), 20, 19);
1130b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("gjnhidfsepkrtaqbmclo"), SV("nocfa"), 20, 18);
1140b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("spocfaktqdbiejlhngmr"), SV("bgtajmiedc"), 20, 19);
1150b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("rphmlekgfscndtaobiqj"), SV("lsckfnqgdahejiopbtmr"), 20, S::npos);
1160b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("liatsqdoegkmfcnbhrpj"), SV(""), 21, 19);
1170b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("binjagtfldkrspcomqeh"), SV("gfsrt"), 21, 19);
1180b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("latkmisecnorjbfhqpdg"), SV("pfsocbhjtm"), 21, 19);
1190b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("lecfratdjkhnsmqpoigb"), SV("tpflmdnoicjgkberhqsa"), 21, S::npos);
1200b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow}
1210b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
1220b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowtemplate <class S, class SV>
1230b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowvoid test1()
1240b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow{
1250b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV(""), S::npos);
1260b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("laenf"), S::npos);
1270b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("pqlnkmbdjo"), S::npos);
1280b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S(""), SV("qkamfogpnljdcshbreti"), S::npos);
1290b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("nhmko"), SV(""), 4);
1300b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("lahfb"), SV("irkhs"), 4);
1310b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("gmfhd"), SV("kantesmpgj"), 4);
1320b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("odaft"), SV("oknlrstdpiqmjbaghcfe"), S::npos);
1330b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("eolhfgpjqk"), SV(""), 9);
1340b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("nbatdlmekr"), SV("bnrpe"), 8);
1350b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("jdmciepkaq"), SV("jtdaefblso"), 9);
1360b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("hkbgspoflt"), SV("oselktgbcapndfjihrmq"), S::npos);
1370b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("gprdcokbnjhlsfmtieqa"), SV(""), 19);
1380b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("qjghlnftcaismkropdeb"), SV("bjaht"), 18);
1390b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("pnalfrdtkqcmojiesbhg"), SV("hjlcmgpket"), 17);
1400b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos);
1410b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow}
1420b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow
1430b9db07158baf145b7a86e023551a8f321fb5696Marshall Clowint main()
1440b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow{
1450b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    {
1460b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    typedef std::string S;
1470b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    typedef std::string_view SV;
1480b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test0<S, SV>();
1490b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    test1<S, SV>();
1500b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    }
1510b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow#if TEST_STD_VER >= 11
1520b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    {
1535d5bbc45abd0532da4b1ce317135f150e4ee37ecStephan T. Lavavej//     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
1545d5bbc45abd0532da4b1ce317135f150e4ee37ecStephan T. Lavavej//     typedef std::string_view SV;
1550b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//     test0<S, SV>();
1560b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow//     test1<S, SV>();
1570b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow    }
1580b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow#endif
1590b9db07158baf145b7a86e023551a8f321fb5696Marshall Clow}
160