]> granicus.if.org Git - php/commitdiff
fix tests, add 64bit versions
authorAntony Dovgal <tony2001@php.net>
Tue, 6 Nov 2007 12:54:13 +0000 (12:54 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 6 Nov 2007 12:54:13 +0000 (12:54 +0000)
18 files changed:
ext/standard/tests/strings/vsprintf_basic7.phpt
ext/standard/tests/strings/vsprintf_basic7_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation11.phpt
ext/standard/tests/strings/vsprintf_variation11_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation12.phpt
ext/standard/tests/strings/vsprintf_variation12_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation13.phpt
ext/standard/tests/strings/vsprintf_variation13_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation14.phpt
ext/standard/tests/strings/vsprintf_variation14_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation15.phpt
ext/standard/tests/strings/vsprintf_variation15_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation16.phpt
ext/standard/tests/strings/vsprintf_variation16_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation19.phpt
ext/standard/tests/strings/vsprintf_variation19_64bit.phpt [new file with mode: 0644]
ext/standard/tests/strings/vsprintf_variation4.phpt
ext/standard/tests/strings/vsprintf_variation4_64bit.phpt [new file with mode: 0644]

index 436471d081a60589b11f8060249d1c3c139f6144..e0e339a7ee2e6ce722252c49fd076ff4a75ee86b 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : basic functionality - unsigned format
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string $format , aaray $args)
diff --git a/ext/standard/tests/strings/vsprintf_basic7_64bit.phpt b/ext/standard/tests/strings/vsprintf_basic7_64bit.phpt
new file mode 100644 (file)
index 0000000..6590b0f
--- /dev/null
@@ -0,0 +1,42 @@
+--TEST--
+Test vsprintf() function : basic functionality - unsigned format
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string $format , aaray $args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+echo "*** Testing vsprintf() : basic functionality - using unsigned format ***\n";
+
+// Initialise all required variables
+$format = "format";
+$format1 = "%u";
+$format2 = "%u %u";
+$format3 = "%u %u %u";
+$arg1 = array(-1111);
+$arg2 = array(-1111,-1234567);
+$arg3 = array(-1111,-1234567,-2345432);
+
+var_dump( vsprintf($format1,$arg1) );
+var_dump( vsprintf($format2,$arg2) );
+var_dump( vsprintf($format3,$arg3) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : basic functionality - using unsigned format ***
+string(20) "18446744073709550505"
+string(41) "18446744073709550505 18446744073708317049"
+string(62) "18446744073709550505 18446744073708317049 18446744073707206184"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : basic functionality - using unsigned format ***
+unicode(20) "18446744073709550505"
+unicode(41) "18446744073709550505 18446744073708317049"
+unicode(62) "18446744073709550505 18446744073708317049 18446744073707206184"
+Done
index 3a48bca1b686d6efcfaae607813241905be279ca..a3cc7c734f5157b6072455e2215dd00a607465f7 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - octal formats with octal values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation11_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation11_64bit.phpt
new file mode 100644 (file)
index 0000000..96ba3ac
--- /dev/null
@@ -0,0 +1,112 @@
+--TEST--
+Test vsprintf() function : usage variations - octal formats with octal values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different octal formats and octal values are passed to
+ * the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : octal formats with octal values ***\n";
+
+// defining array of octal formats
+$formats = array(
+  "%o",
+  "%+o %-o %O",
+  "%lo %Lo, %4o %-4o",
+  "%10.4o %-10.4o %04o %04.4o",
+  "%'#2o %'2o %'$2o %'_2o",
+  "%o %o %o %o",
+  "%% %%o %10 o%",
+  '%3$o %4$o %1$o %2$o'
+);
+
+// Arrays of octal values for the format defined in $format.
+// Each sub array contains octal values which correspond to each format string in $format
+$args_array = array(
+  array(00),
+  array(-01, 01, +022),
+  array(-020000000000, 020000000000, 017777777777, -017777777777),
+  array(0123456, 012345678, -01234567, 01234567),
+  array(0111, 02222, -0333333, -044444444),
+  array(0x123b, 0xfAb, 0123, 01293),
+  array(01234, 05678, -01234, 02345),
+  array(03, 04, 01, 02)
+
+);
+
+// looping to test vsprintf() with different octal formats from the above $formats array
+// and with octal values from the above $args_array array
+$counter = 1;
+foreach($formats as $format) {
+  echo "\n-- Iteration $counter --\n";   
+  var_dump( vsprintf($format, $args_array[$counter-1]) );
+  $counter++;
+}
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing vsprintf() : octal formats with octal values ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(25) "1777777777777777777777 1 "
+
+-- Iteration 3 --
+string(60) "1777777777760000000000 o, 17777777777 1777777777760000000001"
+
+-- Iteration 4 --
+string(49) "                      1777777777777776543211 0000"
+
+-- Iteration 5 --
+string(54) "111 2222 1777777777777777444445 1777777777777733333334"
+
+-- Iteration 6 --
+string(17) "11073 7653 123 12"
+
+-- Iteration 7 --
+string(6) "% %o o"
+
+-- Iteration 8 --
+string(7) "1 2 3 4"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : octal formats with octal values ***
+
+-- Iteration 1 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(25) "1777777777777777777777 1 "
+
+-- Iteration 3 --
+unicode(60) "1777777777760000000000 o, 17777777777 1777777777760000000001"
+
+-- Iteration 4 --
+unicode(49) "                      1777777777777776543211 0000"
+
+-- Iteration 5 --
+unicode(54) "111 2222 1777777777777777444445 1777777777777733333334"
+
+-- Iteration 6 --
+unicode(17) "11073 7653 123 12"
+
+-- Iteration 7 --
+unicode(6) "% %o o"
+
+-- Iteration 8 --
+unicode(7) "1 2 3 4"
+Done
index f588f939052006e87c94bf19d914da01e98872f0..b61df97fdbdb38b9d6d42cd98e92735b0005d7a7 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - octal formats with non-octal values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation12_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation12_64bit.phpt
new file mode 100644 (file)
index 0000000..5f74b60
--- /dev/null
@@ -0,0 +1,156 @@
+--TEST--
+Test vsprintf() function : usage variations - octal formats with non-octal values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different octal formats and non-octal values are passed to
+ * the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : octal formats and non-octal values ***\n";
+
+// defining array of octal formats
+$formats = 
+  '%o %+o %-o 
+   %lo %Lo %4o %-4o
+   %10.4o %-10.4o %.4o 
+   %\'#2o %\'2o %\'$2o %\'_2o
+   %3$o %4$o %1$o %2$o';
+
+// Arrays of non octal values for the format defined in $format.
+// Each sub array contains non octal values which correspond to each format in $format
+$args_array = array(
+
+  // array of float values
+  array(2.2, .2, 10.2,
+        123456.234, 123456.234, -1234.6789, +1234.6789,
+        2e10, +2e12, 22e+12,
+        12345.780, 12.000000011111, -12.00000111111, -123456.234,
+        3.33, +4.44, 1.11,-2.22 ),
+
+  // array of int values
+  array(2, -2, +2,
+        123456, 123456234, -12346789, +12346789,
+        123200, +20000, 22212,
+        12345780, 1211111, -12111111, -12345634,
+        3, +4, 1,-2 ),
+
+  // array of strings
+  array(" ", ' ', 'hello',
+        '123hello', "123hello", '-123hello', '+123hello',
+        "\12345678hello", "-\12345678hello", 'h123456ello',
+        "1234hello", "hello\0world", "NULL", "true",
+        "3", "4", '1', '2'),
+
+  // different arrays
+  array( array(0), array(1, 2), array(-1, -1),
+         array("123"), array('123'), array('-123'), array("-123"),
+         array(true), array(false), array(FALSE),
+         array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
+         array("3"), array("4"), array("1"), array("2") ),
+
+  // array of boolean data
+  array( true, TRUE, false,
+         TRUE, 0, FALSE, 1,
+         true, false, TRUE,
+         0, 1, 1, 0,
+         1, TRUE, 0, FALSE),
+  
+);
+// looping to test vsprintf() with different octal formats from the above $format array
+// and with non-octal values from the above $args_array array
+$counter = 1;
+foreach($args_array as $args) {
+  echo "\n-- Iteration $counter --\n";
+  var_dump( vsprintf($formats, $args) );
+  $counter++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : octal formats and non-octal values ***
+
+-- Iteration 1 --
+string(149) "2 0 12 
+   361100 o 1777777777777777775456 2322
+                          
+   30071 14 1777777777777777777764 1777777777777777416700
+   12 361100 2 0"
+
+-- Iteration 2 --
+string(201) "2 1777777777777777777776 2 
+   361100 o 1777777777777720715133 57062645
+                          
+   57060664 4475347 1777777777777721631371 1777777777777720717336
+   2 361100 2 1777777777777777777776"
+
+-- Iteration 3 --
+string(99) "0 0 0 
+   173 o 1777777777777777777605 173 
+                          
+   2322 0 $0 _0
+   0 173 0 0"
+
+-- Iteration 4 --
+string(75) "1 1 1 
+   1 o    1 1   
+                          
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 5 --
+string(75) "1 1 0 
+   1 o    0 1   
+                          
+   #0 1 $1 _0
+   0 1 1 1"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : octal formats and non-octal values ***
+
+-- Iteration 1 --
+unicode(149) "2 0 12 
+   361100 o 1777777777777777775456 2322
+                          
+   30071 14 1777777777777777777764 1777777777777777416700
+   12 361100 2 0"
+
+-- Iteration 2 --
+unicode(201) "2 1777777777777777777776 2 
+   361100 o 1777777777777720715133 57062645
+                          
+   57060664 4475347 1777777777777721631371 1777777777777720717336
+   2 361100 2 1777777777777777777776"
+
+-- Iteration 3 --
+unicode(99) "0 0 0 
+   173 o 1777777777777777777605 173 
+                          
+   2322 0 $0 _0
+   0 173 0 0"
+
+-- Iteration 4 --
+unicode(75) "1 1 1 
+   1 o    1 1   
+                          
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 5 --
+unicode(75) "1 1 0 
+   1 o    0 1   
+                          
+   #0 1 $1 _0
+   0 1 1 1"
+Done
index 1e2fe6e7f685a086ce7c5915912bc2382aa41847..dc0b20a4a1d58affc6a6ba015bf39965a4eef14c 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - hexa formats with hexa values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation13_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation13_64bit.phpt
new file mode 100644 (file)
index 0000000..036aa8c
--- /dev/null
@@ -0,0 +1,112 @@
+--TEST--
+Test vsprintf() function : usage variations - hexa formats with hexa values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different hexa formats and hexa values are passed to
+ * the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : hexa formats with hexa values ***\n";
+
+// defining array of different hexa formats
+$formats = array(
+  "%x",
+  "%+x %-x %X",
+  "%lx %Lx, %4x %-4x",
+  "%10.4x %-10.4x %04x %04.4x",
+  "%'#2x %'2x %'$2x %'_2x",
+  "%x %x %x %x",
+  "% %%x x%",
+  '%3$x %4$x %1$x %2$x'
+);
+
+// Arrays of hexa values for the format defined in $format.
+// Each sub array contains hexa values which correspond to each format string in $format
+$args_array = array(
+  array(0x0),
+  array(-0x1, 0x1, +0x22),
+  array(0x7FFFFFFF, -0x7fffffff, +0x7000000, -0x80000000),
+  array(123456, 12345678, -1234567, 1234567),
+  array(1, 0x2222, 0333333, -0x44444444),
+  array(0x123b, 0xfAb, "0xaxz", 01293),
+  array(0x1234, 0x34, 0x2ff),
+  array(0x3, 0x4, 0x1, 0x2)
+
+);
+
+// looping to test vsprintf() with different char octal from the above $format array
+// and with octal values from the above $args_array array
+$counter = 1;
+foreach($formats as $format) {
+  echo "\n-- Iteration $counter --\n";   
+  var_dump( vsprintf($format, $args_array[$counter-1]) );
+  $counter++;
+}
+
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing vsprintf() : hexa formats with hexa values ***
+
+-- Iteration 1 --
+string(1) "0"
+
+-- Iteration 2 --
+string(21) "ffffffffffffffff 1 22"
+
+-- Iteration 3 --
+string(36) "7fffffff x, 7000000 ffffffff80000000"
+
+-- Iteration 4 --
+string(43) "                      ffffffffffed2979 0000"
+
+-- Iteration 5 --
+string(30) "#1 2222 1b6db ffffffffbbbbbbbc"
+
+-- Iteration 6 --
+string(12) "123b fab 0 a"
+
+-- Iteration 7 --
+string(5) "%34 x"
+
+-- Iteration 8 --
+string(7) "1 2 3 4"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : hexa formats with hexa values ***
+
+-- Iteration 1 --
+unicode(1) "0"
+
+-- Iteration 2 --
+unicode(21) "ffffffffffffffff 1 22"
+
+-- Iteration 3 --
+unicode(36) "7fffffff x, 7000000 ffffffff80000000"
+
+-- Iteration 4 --
+unicode(43) "                      ffffffffffed2979 0000"
+
+-- Iteration 5 --
+unicode(30) "#1 2222 1b6db ffffffffbbbbbbbc"
+
+-- Iteration 6 --
+unicode(12) "123b fab 0 a"
+
+-- Iteration 7 --
+unicode(5) "%34 x"
+
+-- Iteration 8 --
+unicode(7) "1 2 3 4"
+Done
index 0a5e7b4a9d8d1b414faf48f341c672c7244435f0..149b4812f0f070ba996de78629c07728f296f2d5 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - hexa formats with non-hexa values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation14_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation14_64bit.phpt
new file mode 100644 (file)
index 0000000..281a8ff
--- /dev/null
@@ -0,0 +1,157 @@
+--TEST--
+Test vsprintf() function : usage variations - hexa formats with non-hexa values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different hexa formats and non-hexa values are passed to
+ * the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : hexa formats and non-hexa values ***\n";
+
+// defining array of different hexa formats
+$formats = 
+  '%x %+x %-x 
+   %lx %Lx %4x %-4x
+   %10.4x %-10.4x %.4x 
+   %\'#2x %\'2x %\'$2x %\'_2x
+   %3$x %4$x %1$x %2$x';
+
+// Arrays of non hexa values for the format defined in $format.
+// Each sub array contains non hexa values which correspond to each format in $format
+$args_array = array(
+
+  // array of float values
+  array(2.2, .2, 10.2,
+        123456.234, 123456.234, -1234.6789, +1234.6789,
+        2e10, +2e12, 22e+12,
+        12345.780, 12.000000011111, -12.00000111111, -123456.234,
+        3.33, +4.44, 1.11,-2.22 ),
+
+  // array of int values
+  array(2, -2, +2,
+        123456, 123456234, -12346789, +12346789,
+        123200, +20000, 22212,
+        12345780, 1211111, -12111111, -12345634,
+        3, +4, 1,-2 ),
+
+  // array of strings
+  array(" ", ' ', 'hello',
+        '123hello', "123hello", '-123hello', '+123hello',
+        "\12345678hello", "-\12345678hello", 'h123456ello',
+        "1234hello", "hello\0world", "NULL", "true",
+        "3", "4", '1', '2'),
+
+  // different arrays
+  array( array(0), array(1, 2), array(-1, -1),
+         array("123"), array('123'), array('-123'), array("-123"),
+         array(true), array(TRUE), array(FALSE),
+         array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
+         array("3"), array("4"), array("1"), array("2") ),
+
+  // array of boolean data
+  array( true, TRUE, false,
+         TRUE, 0, FALSE, 1,
+         true, TRUE, FALSE,
+         0, 1, 1, 0,
+         1, TRUE, 0, FALSE),
+  
+);
+
+// looping to test vsprintf() with different hexa formats from the above $format array
+// and with non-hexa values from the above $args_array array
+$counter = 1;
+foreach($args_array as $args) {
+  echo "\n-- Iteration $counter --\n";
+  var_dump( vsprintf($formats, $args) );
+  $counter++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : hexa formats and non-hexa values ***
+
+-- Iteration 1 --
+string(125) "2 0 a 
+   1e240 x fffffffffffffb2e 4d2 
+                          
+   3039 c fffffffffffffff4 fffffffffffe1dc0
+   a 1e240 2 0"
+
+-- Iteration 2 --
+string(164) "2 fffffffffffffffe 2 
+   1e240 x ffffffffff439a5b bc65a5
+                          
+   bc61b4 127ae7 ffffffffff4732f9 ffffffffff439ede
+   2 1e240 2 fffffffffffffffe"
+
+-- Iteration 3 --
+string(90) "0 0 0 
+   7b x ffffffffffffff85 7b  
+                          
+   4d2 0 $0 _0
+   0 7b 0 0"
+
+-- Iteration 4 --
+string(75) "1 1 1 
+   1 x    1 1   
+                          
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 5 --
+string(75) "1 1 0 
+   1 x    0 1   
+                          
+   #0 1 $1 _0
+   0 1 1 1"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : hexa formats and non-hexa values ***
+
+-- Iteration 1 --
+unicode(125) "2 0 a 
+   1e240 x fffffffffffffb2e 4d2 
+                          
+   3039 c fffffffffffffff4 fffffffffffe1dc0
+   a 1e240 2 0"
+
+-- Iteration 2 --
+unicode(164) "2 fffffffffffffffe 2 
+   1e240 x ffffffffff439a5b bc65a5
+                          
+   bc61b4 127ae7 ffffffffff4732f9 ffffffffff439ede
+   2 1e240 2 fffffffffffffffe"
+
+-- Iteration 3 --
+unicode(90) "0 0 0 
+   7b x ffffffffffffff85 7b  
+                          
+   4d2 0 $0 _0
+   0 7b 0 0"
+
+-- Iteration 4 --
+unicode(75) "1 1 1 
+   1 x    1 1   
+                          
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 5 --
+unicode(75) "1 1 0 
+   1 x    0 1   
+                          
+   #0 1 $1 _0
+   0 1 1 1"
+Done
index 02caca59c9d57648bc11f4a72f48c98088f1f20e..01dac33eeac6d1d3a050744568e06240138d517a 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - unsigned formats with unsigned values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt
new file mode 100644 (file)
index 0000000..1035992
--- /dev/null
@@ -0,0 +1,86 @@
+--TEST--
+Test vsprintf() function : usage variations - unsigned formats with unsigned values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different unsigned formats and unsigned values
+ * are passed to the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : unsigned formats and unsigned values ***\n";
+
+// defining array of unsigned formats
+$formats = array(
+  '%u %+u %-u', 
+  '%lu %Lu %4u %-4u',
+  '%10.4u %-10.4u %.4u', 
+  '%\'#2u %\'2u %\'$2u %\'_2u',
+  '%3$u %4$u %1$u %2$u'
+);
+
+// Arrays of unsigned values for the format defined in $format.
+// Each sub array contains unsigned values which correspond to each format string in $format
+$args_array = array(
+  array(1234567, 01234567, 0 ),
+  array(12345678900, 12345678900, 1234, 12345),
+  array("1234000", 10e20, 1.2e2),
+  array(1, 0, 00, "10_"),
+  array(3, 4, 1, 2)
+);
+// looping to test vsprintf() with different unsigned formats from the above $format array
+// and with signed and other types of  values from the above $args_array array
+$counter = 1;
+foreach($formats as $format) {
+  echo "\n-- Iteration $counter --\n";
+  var_dump( vsprintf($format, $args_array[$counter-1]) );
+  $counter++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : unsigned formats and unsigned values ***
+
+-- Iteration 1 --
+string(16) "1234567 342391 0"
+
+-- Iteration 2 --
+string(24) "12345678900 u 1234 12345"
+
+-- Iteration 3 --
+string(25) "   1234000 0          120"
+
+-- Iteration 4 --
+string(10) "#1 0 $0 10"
+
+-- Iteration 5 --
+string(7) "1 2 3 4"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : unsigned formats and unsigned values ***
+
+-- Iteration 1 --
+unicode(16) "1234567 342391 0"
+
+-- Iteration 2 --
+unicode(24) "12345678900 u 1234 12345"
+
+-- Iteration 3 --
+unicode(25) "   1234000 0          120"
+
+-- Iteration 4 --
+unicode(10) "#1 0 $0 10"
+
+-- Iteration 5 --
+unicode(7) "1 2 3 4"
+Done
index 7e76a1282bc2b9da81052c1d01cca5447836c7e2..4bee1341df6a7c0c785b331efe11ebf801cecf60 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - unsigned formats with signed and other types of values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation16_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation16_64bit.phpt
new file mode 100644 (file)
index 0000000..32e28f0
--- /dev/null
@@ -0,0 +1,135 @@
+--TEST--
+Test vsprintf() function : usage variations - unsigned formats with signed and other types of values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different unsigned formats and signed values and other types of values
+ * are passed to the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : unsigned formats and signed & other types of values ***\n";
+
+// defining array of unsigned formats
+$formats = 
+  '%u %+u %-u 
+   %lu %Lu %4u %-4u
+   %10.4u %-10.4u %.4u 
+   %\'#2u %\'2u %\'$2u %\'_2u
+   %3$u %4$u %1$u %2$u';
+
+// Arrays of signed and other type of values for the format defined in $format.
+// Each sub array contains signed values which correspond to each format in $format
+$args_array = array(
+
+  // array of float values
+  array(+2.2, +.2, +10.2,
+        +123456.234, +123456.234, +1234.6789,
+        +2e10, +2e12, +22e+12,
+        +12345.780, +12.000000011111, -12.00000111111, -123456.234,
+        +3.33, +4.44, +1.11,-2.22 ),
+
+  // array of strings
+  array(" ", ' ', 'hello',
+        '123hello', "123hello", '-123hello', '+123hello',
+        "\12345678hello", "-\12345678hello", 'h123456ello',
+        "1234hello", "hello\0world", "NULL", "true",
+        "3", "4", '1', '2'),
+
+  // different arrays
+  array( array(0), array(1, 2), array(-1, -1),
+         array("123"), array('123'), array('-123'), array("-123"),
+         array(true), array(TRUE), array(FALSE),
+         array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
+         array("3"), array("4"), array("1"), array("2") ),
+
+  // array of boolean data
+  array( true, TRUE, false,
+         TRUE, 0, FALSE, 1,
+         true, TRUE, FALSE,
+         0, 1, 1, 0,
+         1, TRUE, 0, FALSE),
+  
+);
+// looping to test vsprintf() with different unsigned formats from the above $format array
+// and with signed and other types of  values from the above $args_array array
+$counter = 1;
+foreach($args_array as $args) {
+  echo "\n-- Iteration $counter --\n";
+  var_dump( vsprintf($formats, $args) );
+  $counter++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : unsigned formats and signed & other types of values ***
+
+-- Iteration 1 --
+string(143) "2 0 10 
+   123456 u 1234 20000000000
+   2000000000000 22000000000000 12345 
+   12 18446744073709551604 18446744073709428160 _3
+   10 123456 2 0"
+
+-- Iteration 2 --
+string(98) "0 0 0 
+   123 u 18446744073709551493 123 
+            0 0          0 
+   1234 0 $0 _0
+   0 123 0 0"
+
+-- Iteration 3 --
+string(76) "1 1 1 
+   1 u    1 1   
+            1 1          1 
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 4 --
+string(76) "1 1 0 
+   1 u    0 1   
+            1 1          0 
+   #0 1 $1 _0
+   0 1 1 1"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : unsigned formats and signed & other types of values ***
+
+-- Iteration 1 --
+unicode(143) "2 0 10 
+   123456 u 1234 20000000000
+   2000000000000 22000000000000 12345 
+   12 18446744073709551604 18446744073709428160 _3
+   10 123456 2 0"
+
+-- Iteration 2 --
+unicode(98) "0 0 0 
+   123 u 18446744073709551493 123 
+            0 0          0 
+   1234 0 $0 _0
+   0 123 0 0"
+
+-- Iteration 3 --
+unicode(76) "1 1 1 
+   1 u    1 1   
+            1 1          1 
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 4 --
+unicode(76) "1 1 0 
+   1 u    0 1   
+            1 1          0 
+   #0 1 $1 _0
+   0 1 1 1"
+Done
index 355793aae7450d50174e7482ddd1ddd99ca6733a..12648088f825b8abd1e46936d2392b0b32eeb43a 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - with whitespaces in format strings
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string $format , array $args)
@@ -121,4 +125,4 @@ unicode(16) "11  FFFFFFDE  33"
 
 -- Iteration 11 --
 unicode(38) "2.000000E+1  2.000000E-1  -2.000000E+1"
-Done
\ No newline at end of file
+Done
diff --git a/ext/standard/tests/strings/vsprintf_variation19_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation19_64bit.phpt
new file mode 100644 (file)
index 0000000..ebb1933
--- /dev/null
@@ -0,0 +1,127 @@
+--TEST--
+Test vsprintf() function : usage variations - with whitespaces in format strings
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string $format , array $args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+echo "*** Testing vsprintf() : with  white spaces in format strings ***\n";
+
+// initializing the format array
+$formats = array(
+  "% d  %  d  %   d",
+  "% f  %  f  %   f",
+  "% F  %  F  %   F",
+  "% b  %  b  %   b",
+  "% c  %  c  %   c",
+  "% e  %  e  %   e",
+  "% u  %  u  %   u",
+  "% o  %  o  %   o",
+  "% x  %  x  %   x",
+  "% X  %  X  %   X",
+  "% E  %  E  %   E"
+);
+
+// initializing the args array
+
+$args_array = array(
+  array(111, 222, 333),
+  array(1.1, .2, -0.6),
+  array(1.12, -1.13, +0.23),
+  array(1, 2, 3),
+  array(65, 66, 67),
+  array(2e1, 2e-1, -2e1),
+  array(-11, +22, 33),
+  array(012, -02394, +02389),
+  array(0x11, -0x22, +0x33),
+  array(0x11, -0x22, +0x33),
+  array(2e1, 2e-1, -2e1)
+);
+
+$counter = 1;
+foreach($formats as $format) {
+  echo"\n-- Iteration $counter --\n";
+  var_dump( vsprintf($format, $args_array[$counter-1]) );
+  $counter++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : with  white spaces in format strings ***
+
+-- Iteration 1 --
+string(13) "111  222  333"
+
+-- Iteration 2 --
+string(29) "1.100000  0.200000  -0.600000"
+
+-- Iteration 3 --
+string(29) "1.120000  -1.130000  0.230000"
+
+-- Iteration 4 --
+string(9) "1  10  11"
+
+-- Iteration 5 --
+string(7) "A  B  C"
+
+-- Iteration 6 --
+string(38) "2.000000e+1  2.000000e-1  -2.000000e+1"
+
+-- Iteration 7 --
+string(28) "18446744073709551605  22  33"
+
+-- Iteration 8 --
+string(30) "12  1777777777777777777755  23"
+
+-- Iteration 9 --
+string(24) "11  ffffffffffffffde  33"
+
+-- Iteration 10 --
+string(24) "11  FFFFFFFFFFFFFFDE  33"
+
+-- Iteration 11 --
+string(38) "2.000000E+1  2.000000E-1  -2.000000E+1"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : with  white spaces in format strings ***
+
+-- Iteration 1 --
+unicode(13) "111  222  333"
+
+-- Iteration 2 --
+unicode(29) "1.100000  0.200000  -0.600000"
+
+-- Iteration 3 --
+unicode(29) "1.120000  -1.130000  0.230000"
+
+-- Iteration 4 --
+unicode(9) "1  10  11"
+
+-- Iteration 5 --
+unicode(7) "A  B  C"
+
+-- Iteration 6 --
+unicode(38) "2.000000e+1  2.000000e-1  -2.000000e+1"
+
+-- Iteration 7 --
+unicode(28) "18446744073709551605  22  33"
+
+-- Iteration 8 --
+unicode(30) "12  1777777777777777777755  23"
+
+-- Iteration 9 --
+unicode(24) "11  ffffffffffffffde  33"
+
+-- Iteration 10 --
+unicode(24) "11  FFFFFFFFFFFFFFDE  33"
+
+-- Iteration 11 --
+unicode(38) "2.000000E+1  2.000000E-1  -2.000000E+1"
+Done
index f9afe74a3caa30b2376318e71cf43cd4256bfbc8..37c9c606e9cde6defb4cedf91ca12f92cb8b269f 100644 (file)
@@ -1,5 +1,9 @@
 --TEST--
 Test vsprintf() function : usage variations - int formats with non-integer values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
 --FILE--
 <?php
 /* Prototype  : string vsprintf(string format, array args)
diff --git a/ext/standard/tests/strings/vsprintf_variation4_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation4_64bit.phpt
new file mode 100644 (file)
index 0000000..99f48e9
--- /dev/null
@@ -0,0 +1,135 @@
+--TEST--
+Test vsprintf() function : usage variations - int formats with non-integer values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+/* Prototype  : string vsprintf(string format, array args)
+ * Description: Return a formatted string 
+ * Source code: ext/standard/formatted_print.c
+*/
+
+/*
+ * Test vsprintf() when different int formats and non-int values are passed to
+ * the '$format' and '$args' arguments of the function
+*/
+
+echo "*** Testing vsprintf() : int formats and non-integer values ***\n";
+
+// defining array of int formats
+$formats = 
+  '%d %+d %-d 
+   %ld %Ld %4d %-4d
+   %10.4d %-10.4d %.4d %04.4d
+   %\'#2d %\'2d %\'$2d %\'_2d
+   %3$d %4$d %1$d %2$d';
+
+// Arrays of non int values for the format defined in $format.
+// Each sub array contains non int values which correspond to each format in $format
+$args_array = array(
+
+  // array of float values
+  array(2.2, .2, 10.2,
+        123456.234, 123456.234, -1234.6789, +1234.6789,
+        2e10, +2e5, 4e3, 22e+6,
+        12345.780, 12.000000011111, -12.00000111111, -123456.234,
+        3.33, +4.44, 1.11,-2.22 ),
+
+  // array of strings
+  array(" ", ' ', 'hello',
+        '123hello', "123hello", '-123hello', '+123hello',
+        "\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello',
+        "1234hello", "hello\0world", "NULL", "true",
+        "3", "4", '1', '2'),
+
+  // different arrays
+  array( array(0), array(1, 2), array(-1, -1),
+         array("123"), array('123'), array('-123'), array("-123"),
+         array(true), array(false), array(TRUE), array(FALSE),
+         array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
+         array("3"), array("4"), array("1"), array("2") ),
+
+  // array of boolean data
+  array( true, TRUE, false,
+         TRUE, 0, FALSE, 1,
+         true, false, TRUE, FALSE,
+         0, 1, 1, 0,
+         1, TRUE, 0, FALSE),
+  
+);
+
+// looping to test vsprintf() with different int formats from the above $format array
+// and with non-int values from the above $args_array array
+$counter = 1;
+foreach($args_array as $args) {
+  echo "\n-- Iteration $counter --\n";
+  var_dump( vsprintf($formats, $args) );
+  $counter++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing vsprintf() : int formats and non-integer values ***
+
+-- Iteration 1 --
+string(112) "2 +0 10 
+   123456 d -1234 1234
+   20000000000 200000     4000 22000000
+   12345 12 -12 -123456
+   10 123456 2 0"
+
+-- Iteration 2 --
+string(92) "0 +0 0 
+   123 d -123 123 
+            0 0          123456 0000
+   1234 0 $0 _0
+   0 123 0 0"
+
+-- Iteration 3 --
+string(81) "1 +1 1 
+   1 d    1 1   
+            1 1          1 0001
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 4 --
+string(81) "1 +1 0 
+   1 d    0 1   
+            1 0          1 0000
+   #0 1 $1 _0
+   0 1 1 1"
+Done
+--UEXPECTF--
+*** Testing vsprintf() : int formats and non-integer values ***
+
+-- Iteration 1 --
+unicode(112) "2 +0 10 
+   123456 d -1234 1234
+   20000000000 200000     4000 22000000
+   12345 12 -12 -123456
+   10 123456 2 0"
+
+-- Iteration 2 --
+unicode(92) "0 +0 0 
+   123 d -123 123 
+            0 0          123456 0000
+   1234 0 $0 _0
+   0 123 0 0"
+
+-- Iteration 3 --
+unicode(81) "1 +1 1 
+   1 d    1 1   
+            1 1          1 0001
+   #1 1 $1 _1
+   1 1 1 1"
+
+-- Iteration 4 --
+unicode(81) "1 +1 0 
+   1 d    0 1   
+            1 0          1 0000
+   #0 1 $1 _0
+   0 1 1 1"
+Done