pointer_size.pass.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <string>
  10. // size_type find_first_of(const charT* s, size_type pos = 0) const;
  11. #include <string>
  12. #include <cassert>
  13. template <class S>
  14. void
  15. test(const S& s, const typename S::value_type* str, typename S::size_type pos,
  16. typename S::size_type x)
  17. {
  18. assert(s.find_first_of(str, pos) == x);
  19. if (x != S::npos)
  20. assert(pos <= x && x < s.size());
  21. }
  22. template <class S>
  23. void
  24. test(const S& s, const typename S::value_type* str, typename S::size_type x)
  25. {
  26. assert(s.find_first_of(str) == x);
  27. if (x != S::npos)
  28. assert(x < s.size());
  29. }
  30. typedef std::string S;
  31. void test0()
  32. {
  33. test(S(""), "", 0, S::npos);
  34. test(S(""), "laenf", 0, S::npos);
  35. test(S(""), "pqlnkmbdjo", 0, S::npos);
  36. test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
  37. test(S(""), "", 1, S::npos);
  38. test(S(""), "bjaht", 1, S::npos);
  39. test(S(""), "hjlcmgpket", 1, S::npos);
  40. test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
  41. test(S("fodgq"), "", 0, S::npos);
  42. test(S("qanej"), "dfkap", 0, 1);
  43. test(S("clbao"), "ihqrfebgad", 0, 2);
  44. test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
  45. test(S("srdfq"), "", 1, S::npos);
  46. test(S("oemth"), "ikcrq", 1, S::npos);
  47. test(S("cdaih"), "dmajblfhsg", 1, 1);
  48. test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
  49. test(S("cshmd"), "", 2, S::npos);
  50. test(S("lhcdo"), "oebqi", 2, 4);
  51. test(S("qnsoh"), "kojhpmbsfe", 2, 2);
  52. test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
  53. test(S("fmtsp"), "", 4, S::npos);
  54. test(S("khbpm"), "aobjd", 4, S::npos);
  55. test(S("pbsji"), "pcbahntsje", 4, S::npos);
  56. test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
  57. test(S("eqmpa"), "", 5, S::npos);
  58. test(S("omigs"), "kocgb", 5, S::npos);
  59. test(S("onmje"), "fbslrjiqkm", 5, S::npos);
  60. test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
  61. test(S("schfa"), "", 6, S::npos);
  62. test(S("igdsc"), "qngpd", 6, S::npos);
  63. test(S("brqgo"), "rodhqklgmb", 6, S::npos);
  64. test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
  65. test(S("hcjitbfapl"), "", 0, S::npos);
  66. test(S("daiprenocl"), "ashjd", 0, 0);
  67. test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
  68. test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
  69. test(S("qpghtfbaji"), "", 1, S::npos);
  70. test(S("gfshlcmdjr"), "nadkh", 1, 3);
  71. test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
  72. test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
  73. test(S("crnklpmegd"), "", 5, S::npos);
  74. test(S("jsbtafedoc"), "prqgn", 5, S::npos);
  75. test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
  76. test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
  77. test(S("lmofqdhpki"), "", 9, S::npos);
  78. test(S("hnefkqimca"), "rtjpa", 9, 9);
  79. test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
  80. test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
  81. test(S("elgofjmbrq"), "", 10, S::npos);
  82. test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
  83. test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
  84. test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
  85. test(S("eqsgalomhb"), "", 11, S::npos);
  86. test(S("akiteljmoh"), "lofbc", 11, S::npos);
  87. test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
  88. test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
  89. test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
  90. test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
  91. test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
  92. test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
  93. test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
  94. test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
  95. test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
  96. test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
  97. test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
  98. test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
  99. test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
  100. test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
  101. test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
  102. test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
  103. test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
  104. test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
  105. test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
  106. test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
  107. test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
  108. test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
  109. test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
  110. test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
  111. test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
  112. test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
  113. }
  114. void test1()
  115. {
  116. test(S(""), "", S::npos);
  117. test(S(""), "laenf", S::npos);
  118. test(S(""), "pqlnkmbdjo", S::npos);
  119. test(S(""), "qkamfogpnljdcshbreti", S::npos);
  120. test(S("nhmko"), "", S::npos);
  121. test(S("lahfb"), "irkhs", 2);
  122. test(S("gmfhd"), "kantesmpgj", 0);
  123. test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
  124. test(S("eolhfgpjqk"), "", S::npos);
  125. test(S("nbatdlmekr"), "bnrpe", 0);
  126. test(S("jdmciepkaq"), "jtdaefblso", 0);
  127. test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
  128. test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
  129. test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
  130. test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
  131. test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
  132. }
  133. int main()
  134. {
  135. test0();
  136. test1();
  137. }