vprintf_variation19.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. --TEST--
  2. Test vprintf() function : usage variations - with whitespaces in format strings
  3. --SKIPIF--
  4. <?php
  5. if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
  6. ?>
  7. --FILE--
  8. <?php
  9. echo "*** Testing vprintf() : with white spaces in format strings ***\n";
  10. // initializing the format array
  11. $formats = array(
  12. "% d % d % d",
  13. "% f % f % f",
  14. "% F % F % F",
  15. "% b % b % b",
  16. "% c % c % c",
  17. "% e % e % e",
  18. "% u % u % u",
  19. "% o % o % o",
  20. "% x % x % x",
  21. "% X % X % X",
  22. "% E % E % E"
  23. );
  24. // initializing the args array
  25. $args_array = array(
  26. array(111, 222, 333),
  27. array(1.1, .2, -0.6),
  28. array(1.12, -1.13, +0.23),
  29. array(1, 2, 3),
  30. array(65, 66, 67),
  31. array(2e1, 2e-1, -2e1),
  32. array(-11, +22, 33),
  33. array(012, -023, +023),
  34. array(0x11, -0x22, +0x33),
  35. array(0x11, -0x22, +0x33),
  36. array(2e1, 2e-1, -2e1)
  37. );
  38. $counter = 1;
  39. foreach($formats as $format) {
  40. echo"\n-- Iteration $counter --\n";
  41. $result = vprintf($format, $args_array[$counter-1]);
  42. echo "\n";
  43. var_dump($result);
  44. $counter++;
  45. }
  46. ?>
  47. --EXPECT--
  48. *** Testing vprintf() : with white spaces in format strings ***
  49. -- Iteration 1 --
  50. 111 222 333
  51. int(13)
  52. -- Iteration 2 --
  53. 1.100000 0.200000 -0.600000
  54. int(29)
  55. -- Iteration 3 --
  56. 1.120000 -1.130000 0.230000
  57. int(29)
  58. -- Iteration 4 --
  59. 1 10 11
  60. int(9)
  61. -- Iteration 5 --
  62. A B C
  63. int(7)
  64. -- Iteration 6 --
  65. 2.000000e+1 2.000000e-1 -2.000000e+1
  66. int(38)
  67. -- Iteration 7 --
  68. 4294967285 22 33
  69. int(18)
  70. -- Iteration 8 --
  71. 12 37777777755 23
  72. int(19)
  73. -- Iteration 9 --
  74. 11 ffffffde 33
  75. int(16)
  76. -- Iteration 10 --
  77. 11 FFFFFFDE 33
  78. int(16)
  79. -- Iteration 11 --
  80. 2.000000E+1 2.000000E-1 -2.000000E+1
  81. int(38)