vprintf_variation15.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --TEST--
  2. Test vprintf() function : usage variations - unsigned formats with unsigned values
  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. /*
  10. * Test vprintf() when different unsigned formats and unsigned values
  11. * are passed to the '$format' and '$args' arguments of the function
  12. */
  13. echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n";
  14. // defining array of unsigned formats
  15. $formats = array(
  16. '%u %+u %-u',
  17. '%lu %4u %-4u',
  18. '%10.4u %-10.4u %.4u',
  19. '%\'#2u %\'2u %\'$2u %\'_2u',
  20. '%3$u %4$u %1$u %2$u'
  21. );
  22. // Arrays of unsigned values for the format defined in $format.
  23. // Each sub array contains unsigned values which correspond to each format string in $format
  24. $args_array = array(
  25. array(1234567, 01234567, 0 ),
  26. array(12345678900, 1234, 12345),
  27. array("1234000", 10.1234567e10, 1.2e2),
  28. array(1, 0, 00, "10_"),
  29. array(3, 4, 1, 2)
  30. );
  31. // looping to test vprintf() with different unsigned formats from the above $format array
  32. // and with signed and other types of values from the above $args_array array
  33. $counter = 1;
  34. foreach($formats as $format) {
  35. echo "\n-- Iteration $counter --\n";
  36. $result = vprintf($format, $args_array[$counter-1]);
  37. echo "\n";
  38. var_dump($result);
  39. $counter++;
  40. }
  41. ?>
  42. --EXPECT--
  43. *** Testing vprintf() : unsigned formats and unsigned values ***
  44. -- Iteration 1 --
  45. 1234567 342391 0
  46. int(16)
  47. -- Iteration 2 --
  48. 3755744308 1234 12345
  49. int(21)
  50. -- Iteration 3 --
  51. 1234000 2450319192 120
  52. int(25)
  53. -- Iteration 4 --
  54. #1 0 $0 10
  55. int(10)
  56. -- Iteration 5 --
  57. 1 2 3 4
  58. int(7)