strcspn_variation10.phpt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. --TEST--
  2. Test strcspn() function : usage variations - with varying mask & default start and len args
  3. --FILE--
  4. <?php
  5. /*
  6. * Testing strcspn() : with varying mask and default start and len arguments
  7. */
  8. echo "*** Testing strcspn() : with different mask strings and default start and len arguments ***\n";
  9. // initialing required variables
  10. $strings = array(
  11. "",
  12. '',
  13. "\n",
  14. '\n',
  15. "hello\tworld\nhello\nworld\n",
  16. 'hello\tworld\nhello\nworld\n',
  17. "1234hello45world\t123",
  18. '1234hello45world\t123',
  19. "hello\0world\012",
  20. 'hello\0world\012',
  21. chr(0).chr(0),
  22. chr(0)."hello\0world".chr(0),
  23. chr(0).'hello\0world'.chr(0),
  24. "hello".chr(0)."world",
  25. 'hello'.chr(0).'world',
  26. "hello\0\100\xaaaworld",
  27. 'hello\0\100\xaaaworld'
  28. );
  29. // defining array of mask strings
  30. $mask_array = array(
  31. "",
  32. '',
  33. "\n\trsti \l",
  34. '\n\trsti \l',
  35. "\t",
  36. "t\ ",
  37. '\t',
  38. "\t\ ",
  39. " \t",
  40. "\t\i\100\xa"
  41. );
  42. // loop through each element of the array for mask argument
  43. $count = 1;
  44. foreach($strings as $str) {
  45. echo "\n-- Itearation $count --\n";
  46. foreach($mask_array as $mask) {
  47. var_dump( strcspn($str,$mask) );
  48. }
  49. $count++;
  50. }
  51. echo "Done"
  52. ?>
  53. --EXPECT--
  54. *** Testing strcspn() : with different mask strings and default start and len arguments ***
  55. -- Itearation 1 --
  56. int(0)
  57. int(0)
  58. int(0)
  59. int(0)
  60. int(0)
  61. int(0)
  62. int(0)
  63. int(0)
  64. int(0)
  65. int(0)
  66. -- Itearation 2 --
  67. int(0)
  68. int(0)
  69. int(0)
  70. int(0)
  71. int(0)
  72. int(0)
  73. int(0)
  74. int(0)
  75. int(0)
  76. int(0)
  77. -- Itearation 3 --
  78. int(1)
  79. int(1)
  80. int(0)
  81. int(1)
  82. int(1)
  83. int(1)
  84. int(1)
  85. int(1)
  86. int(1)
  87. int(0)
  88. -- Itearation 4 --
  89. int(2)
  90. int(2)
  91. int(0)
  92. int(0)
  93. int(2)
  94. int(0)
  95. int(0)
  96. int(0)
  97. int(2)
  98. int(0)
  99. -- Itearation 5 --
  100. int(24)
  101. int(24)
  102. int(2)
  103. int(2)
  104. int(5)
  105. int(24)
  106. int(24)
  107. int(5)
  108. int(5)
  109. int(5)
  110. -- Itearation 6 --
  111. int(28)
  112. int(28)
  113. int(2)
  114. int(2)
  115. int(28)
  116. int(5)
  117. int(5)
  118. int(5)
  119. int(28)
  120. int(5)
  121. -- Itearation 7 --
  122. int(20)
  123. int(20)
  124. int(6)
  125. int(6)
  126. int(16)
  127. int(20)
  128. int(20)
  129. int(16)
  130. int(16)
  131. int(16)
  132. -- Itearation 8 --
  133. int(21)
  134. int(21)
  135. int(6)
  136. int(6)
  137. int(21)
  138. int(16)
  139. int(16)
  140. int(16)
  141. int(21)
  142. int(16)
  143. -- Itearation 9 --
  144. int(5)
  145. int(5)
  146. int(2)
  147. int(2)
  148. int(12)
  149. int(12)
  150. int(12)
  151. int(12)
  152. int(12)
  153. int(11)
  154. -- Itearation 10 --
  155. int(16)
  156. int(16)
  157. int(2)
  158. int(2)
  159. int(16)
  160. int(5)
  161. int(5)
  162. int(5)
  163. int(16)
  164. int(5)
  165. -- Itearation 11 --
  166. int(0)
  167. int(0)
  168. int(2)
  169. int(2)
  170. int(2)
  171. int(2)
  172. int(2)
  173. int(2)
  174. int(2)
  175. int(2)
  176. -- Itearation 12 --
  177. int(0)
  178. int(0)
  179. int(3)
  180. int(3)
  181. int(13)
  182. int(13)
  183. int(13)
  184. int(13)
  185. int(13)
  186. int(13)
  187. -- Itearation 13 --
  188. int(0)
  189. int(0)
  190. int(3)
  191. int(3)
  192. int(14)
  193. int(6)
  194. int(6)
  195. int(6)
  196. int(14)
  197. int(6)
  198. -- Itearation 14 --
  199. int(5)
  200. int(5)
  201. int(2)
  202. int(2)
  203. int(11)
  204. int(11)
  205. int(11)
  206. int(11)
  207. int(11)
  208. int(11)
  209. -- Itearation 15 --
  210. int(5)
  211. int(5)
  212. int(2)
  213. int(2)
  214. int(11)
  215. int(11)
  216. int(11)
  217. int(11)
  218. int(11)
  219. int(11)
  220. -- Itearation 16 --
  221. int(5)
  222. int(5)
  223. int(2)
  224. int(2)
  225. int(14)
  226. int(14)
  227. int(14)
  228. int(14)
  229. int(14)
  230. int(6)
  231. -- Itearation 17 --
  232. int(21)
  233. int(21)
  234. int(2)
  235. int(2)
  236. int(21)
  237. int(5)
  238. int(5)
  239. int(5)
  240. int(21)
  241. int(5)
  242. Done