array_pad.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. --TEST--
  2. array_pad() tests
  3. --FILE--
  4. <?php
  5. var_dump(array_pad());
  6. var_dump(array_pad(array()));
  7. var_dump(array_pad(array(), 1));
  8. var_dump(array_pad(array(), 1, 0));
  9. var_dump(array_pad(array(), 0, 0));
  10. var_dump(array_pad(array(), -1, 0));
  11. var_dump(array_pad(array("", -1, 2.0), 5, 0));
  12. var_dump(array_pad(array("", -1, 2.0), 5, array()));
  13. var_dump(array_pad(array("", -1, 2.0), 2, array()));
  14. var_dump(array_pad(array("", -1, 2.0), -3, array()));
  15. var_dump(array_pad(array("", -1, 2.0), -4, array()));
  16. var_dump(array_pad(array("", -1, 2.0), 2000000, 0));
  17. var_dump(array_pad("", 2000000, 0));
  18. echo "Done\n";
  19. ?>
  20. --EXPECTF--
  21. Warning: array_pad() expects exactly 3 parameters, 0 given in %s on line %d
  22. NULL
  23. Warning: array_pad() expects exactly 3 parameters, 1 given in %s on line %d
  24. NULL
  25. Warning: array_pad() expects exactly 3 parameters, 2 given in %s on line %d
  26. NULL
  27. array(1) {
  28. [0]=>
  29. int(0)
  30. }
  31. array(0) {
  32. }
  33. array(1) {
  34. [0]=>
  35. int(0)
  36. }
  37. array(5) {
  38. [0]=>
  39. string(0) ""
  40. [1]=>
  41. int(-1)
  42. [2]=>
  43. float(2)
  44. [3]=>
  45. int(0)
  46. [4]=>
  47. int(0)
  48. }
  49. array(5) {
  50. [0]=>
  51. string(0) ""
  52. [1]=>
  53. int(-1)
  54. [2]=>
  55. float(2)
  56. [3]=>
  57. array(0) {
  58. }
  59. [4]=>
  60. array(0) {
  61. }
  62. }
  63. array(3) {
  64. [0]=>
  65. string(0) ""
  66. [1]=>
  67. int(-1)
  68. [2]=>
  69. float(2)
  70. }
  71. array(3) {
  72. [0]=>
  73. string(0) ""
  74. [1]=>
  75. int(-1)
  76. [2]=>
  77. float(2)
  78. }
  79. array(4) {
  80. [0]=>
  81. array(0) {
  82. }
  83. [1]=>
  84. string(0) ""
  85. [2]=>
  86. int(-1)
  87. [3]=>
  88. float(2)
  89. }
  90. Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d
  91. bool(false)
  92. Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d
  93. NULL
  94. Done