kraghuba                Fri Sep 14 19:09:11 2007 UTC

  Modified files:              
    /php-src/ext/standard/tests/strings wordwrap_variation1.phpt 
                                        wordwrap_variation2.phpt 
                                        wordwrap_variation3.phpt 
                                        wordwrap_variation4.phpt 
                                        wordwrap_variation5.phpt 
                                        wordwrap_basic.phpt 
                                        wordwrap_error.phpt 
  Log:
  New testcases for wordwrap()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/wordwrap_variation1.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_variation1.phpt Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,335 @@
+--TEST--
+Test wordwrap() function : usage variations  - unexpected values for str 
argument
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * testing wordwrap() by providing different values for str argument
+*/
+
+echo "*** Testing wordwrap() : usage variations ***\n";
+// initialize all required variables
+$width = 3;
+$break = '<br />\n';
+$cut = true;
+
+// resource variable
+$fp = fopen(__FILE__, "r");
+
+// get an unset variable
+$unset_var = 'string_val';
+unset($unset_var);
+
+// array with different values
+$values =  array (
+
+  // integer values
+  0,
+  1,
+  12345,
+  -2345,
+
+  // float values
+  10.5,
+  -10.5,
+  10.5e10,
+  10.6E-10,
+  .5,
+
+  // array values
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => 'red', 'item' => 'pen'),
+
+  // boolean values
+  true,
+  false,
+  TRUE,
+  FALSE,
+
+  // objects
+  new stdclass(),
+
+  // Null
+  NULL,
+  null,
+
+  // empty string
+  "",
+  '',
+
+  // resource variable
+  $fp,
+
+  // undefined variable
+  @$undefined_var,
+
+  // unset variable
+  @$unset_var
+);
+
+// loop though each element of the array and check the working of wordwrap()
+// when $str arugment is supplied with different values
+echo "\n--- Testing wordwrap() by supplying different values for 'str' 
argument ---\n";
+$counter = 1;
+for($index = 0; $index < count($values); $index ++) {
+  echo "-- Iteration $counter --\n";
+  $str = $values [$index];
+
+  var_dump( wordwrap($str) );
+  var_dump( wordwrap($str, $width) );
+  var_dump( wordwrap($str, $width, $break) );
+
+  // $cut as false
+  $cut = false;
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  // $cut as true
+  $cut = true;
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  $counter ++;
+}
+
+// close the resource 
+fclose($fp);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : usage variations ***
+
+--- Testing wordwrap() by supplying different values for 'str' argument ---
+-- Iteration 1 --
+string(1) "0"
+string(1) "0"
+string(1) "0"
+string(1) "0"
+string(1) "0"
+-- Iteration 2 --
+string(1) "1"
+string(1) "1"
+string(1) "1"
+string(1) "1"
+string(1) "1"
+-- Iteration 3 --
+string(5) "12345"
+string(5) "12345"
+string(5) "12345"
+string(5) "12345"
+string(13) "123<br />\n45"
+-- Iteration 4 --
+string(5) "-2345"
+string(5) "-2345"
+string(5) "-2345"
+string(5) "-2345"
+string(13) "-23<br />\n45"
+-- Iteration 5 --
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(12) "10.<br />\n5"
+-- Iteration 6 --
+string(5) "-10.5"
+string(5) "-10.5"
+string(5) "-10.5"
+string(5) "-10.5"
+string(13) "-10<br />\n.5"
+-- Iteration 7 --
+string(12) "105000000000"
+string(12) "105000000000"
+string(12) "105000000000"
+string(12) "105000000000"
+string(36) "105<br />\n000<br />\n000<br />\n000"
+-- Iteration 8 --
+string(7) "1.06E-9"
+string(7) "1.06E-9"
+string(7) "1.06E-9"
+string(7) "1.06E-9"
+string(23) "1.0<br />\n6E-<br />\n9"
+-- Iteration 9 --
+string(3) "0.5"
+string(3) "0.5"
+string(3) "0.5"
+string(3) "0.5"
+string(3) "0.5"
+-- Iteration 10 --
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 11 --
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 12 --
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 13 --
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 14 --
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 15 --
+string(1) "1"
+string(1) "1"
+string(1) "1"
+string(1) "1"
+string(1) "1"
+-- Iteration 16 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 17 --
+string(1) "1"
+string(1) "1"
+string(1) "1"
+string(1) "1"
+string(1) "1"
+-- Iteration 18 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 19 --
+
+Warning: wordwrap() expects parameter 1 to be string, object given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, object given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, object given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, object given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, object given in %s on 
line %d
+NULL
+-- Iteration 20 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 21 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 22 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 23 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 24 --
+
+Warning: wordwrap() expects parameter 1 to be string, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 1 to be string, resource given in %s on 
line %d
+NULL
+-- Iteration 25 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 26 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_variation2.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/wordwrap_variation2.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_variation2.phpt Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,340 @@
+--TEST--
+Test wordwrap() function : usage variations  - unexpected values for width 
argument
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * test wordwrap by passing different values for width argument 
+*/
+echo "*** Testing wordwrap() : usage variations ***\n";
+// initialize all required variables
+$str = 'testing wordwrap function';
+$break = '<br />\n';
+$cut = true;
+
+// resource var 
+$fp = fopen(__FILE__, "r");
+
+// get an unset variable
+$unset_var = 10;
+unset($unset_var);
+
+
+// array with different values as width
+$values =  array (
+  // zerovalue for width
+  0,
+
+  // -ve value for width
+  -1,
+  -10,
+
+  // array values
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => 'red', 'item' => 'pen'),
+
+  // boolean values
+  true,
+  false,
+  TRUE,
+  FALSE,
+
+  // string values
+  "string",
+  'string',
+
+  // objects
+  new stdclass(),
+
+  // Null value 
+  NULL,
+  null,
+
+  // empty string
+  "",
+  '',
+
+  // resource variable
+  $fp,
+
+  // undefined variable
+  @$undefined_var,
+
+  // unset variable
+  @$unset_var
+);
+
+
+// loop though each element of the array and check the working of wordwrap()
+// when $width arugment is supplied with different values
+echo "\n--- Testing wordwrap() by supplying different values for 'width' 
argument ---\n";
+$counter = 1;
+for($index = 0; $index < count($values); $index ++) {
+  echo "-- Iteration $counter --\n";
+  $width = $values [$index];
+
+  var_dump( wordwrap($str, $width) );
+  var_dump( wordwrap($str, $width, $break) );
+
+  // cut as false 
+  $cut = false;
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  // cut as true
+  $cut = true;
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  $counter ++;
+}
+
+// close the resource
+fclose($fp);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : usage variations ***
+
+--- Testing wordwrap() by supplying different values for 'width' argument ---
+-- Iteration 1 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- Iteration 2 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br 
/>\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br 
/>\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br 
/>\nn"
+-- Iteration 3 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br 
/>\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br 
/>\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br 
/>\nn"
+-- Iteration 4 --
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+-- Iteration 5 --
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+-- Iteration 6 --
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+-- Iteration 7 --
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+-- Iteration 8 --
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, array given in %s on line 
%d
+NULL
+-- Iteration 9 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(199) "t<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br 
/>\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br 
/>\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
+-- Iteration 10 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- Iteration 11 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(199) "t<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br 
/>\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br 
/>\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
+-- Iteration 12 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- Iteration 13 --
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+-- Iteration 14 --
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+-- Iteration 15 --
+
+Warning: wordwrap() expects parameter 2 to be long, object given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, object given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, object given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, object given in %s on line 
%d
+NULL
+-- Iteration 16 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- Iteration 17 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- Iteration 18 --
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+-- Iteration 19 --
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+-- Iteration 20 --
+
+Warning: wordwrap() expects parameter 2 to be long, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 2 to be long, resource given in %s on 
line %d
+NULL
+-- Iteration 21 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- Iteration 22 --
+string(25) "testing
+wordwrap
+function"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_variation3.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/wordwrap_variation3.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_variation3.phpt Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,302 @@
+--TEST--
+Test wordwrap() function : usage variations  - unexptected values for break 
argument
+--INI--
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * test wordwrap by passing different values for break argument 
+*/
+echo "*** Testing wordwrap() : usage variations ***\n";
+// initialize all required variables
+$str = 'testing wordwrap function';
+$width = 10;
+$cut = true;
+
+// resource var
+$fp = fopen(__FILE__, "r");
+
+// get an unset variable
+$unset_var = 'string_val';
+unset($unset_var);
+
+
+// array with different values for break arg
+$values =  array (
+
+  // integer values
+  0,
+  1,
+  12345,
+  -2345,
+
+  // float values
+  10.5,
+  -10.5,
+  10.5e10,
+  10.6E-10,
+  .5,
+
+  // array values
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => 'red', 'item' => 'pen'),
+
+  // boolean values
+  true,
+  false,
+  TRUE,
+  FALSE,
+
+  // objects
+  new stdclass(),
+
+  // empty string
+  "",
+  '',
+
+  //Null
+  NULL,
+  null,
+
+  // resource var
+  $fp,
+
+  // undefined variable
+  @$undefined_var,
+
+  // unset variable
+  @$unset_var
+);
+
+// loop though each element of the array and check the working of wordwrap()
+// when $break arugment is supplied with different values
+echo "\n--- Testing wordwrap() by supplying different values for 'break' 
argument ---\n";
+$counter = 1;
+for($index = 0; $index < count($values); $index ++) {
+  echo "-- Iteration $counter --\n";
+  $break = $values [$index];
+
+  var_dump( wordwrap($str, $width, $break) );
+
+  // $cut as false
+  $cut = false;
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  // $cut as true 
+  $cut = true;
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  $counter ++;
+}
+
+// close the resource used
+fclose($fp);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : usage variations ***
+
+--- Testing wordwrap() by supplying different values for 'break' argument ---
+-- Iteration 1 --
+string(25) "testing0wordwrap0function"
+string(25) "testing0wordwrap0function"
+string(25) "testing0wordwrap0function"
+-- Iteration 2 --
+string(25) "testing1wordwrap1function"
+string(25) "testing1wordwrap1function"
+string(25) "testing1wordwrap1function"
+-- Iteration 3 --
+string(33) "testing12345wordwrap12345function"
+string(33) "testing12345wordwrap12345function"
+string(33) "testing12345wordwrap12345function"
+-- Iteration 4 --
+string(33) "testing-2345wordwrap-2345function"
+string(33) "testing-2345wordwrap-2345function"
+string(33) "testing-2345wordwrap-2345function"
+-- Iteration 5 --
+string(31) "testing10.5wordwrap10.5function"
+string(31) "testing10.5wordwrap10.5function"
+string(31) "testing10.5wordwrap10.5function"
+-- Iteration 6 --
+string(33) "testing-10.5wordwrap-10.5function"
+string(33) "testing-10.5wordwrap-10.5function"
+string(33) "testing-10.5wordwrap-10.5function"
+-- Iteration 7 --
+string(47) "testing105000000000wordwrap105000000000function"
+string(47) "testing105000000000wordwrap105000000000function"
+string(47) "testing105000000000wordwrap105000000000function"
+-- Iteration 8 --
+string(37) "testing1.06E-9wordwrap1.06E-9function"
+string(37) "testing1.06E-9wordwrap1.06E-9function"
+string(37) "testing1.06E-9wordwrap1.06E-9function"
+-- Iteration 9 --
+string(29) "testing0.5wordwrap0.5function"
+string(29) "testing0.5wordwrap0.5function"
+string(29) "testing0.5wordwrap0.5function"
+-- Iteration 10 --
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 11 --
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 12 --
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 13 --
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 14 --
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, array given in %s on 
line %d
+NULL
+-- Iteration 15 --
+string(25) "testing1wordwrap1function"
+string(25) "testing1wordwrap1function"
+string(25) "testing1wordwrap1function"
+-- Iteration 16 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 17 --
+string(25) "testing1wordwrap1function"
+string(25) "testing1wordwrap1function"
+string(25) "testing1wordwrap1function"
+-- Iteration 18 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 19 --
+
+Warning: wordwrap() expects parameter 3 to be string, object given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, object given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, object given in %s on 
line %d
+NULL
+-- Iteration 20 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 21 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 22 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 23 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 24 --
+
+Warning: wordwrap() expects parameter 3 to be string, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, resource given in %s on 
line %d
+NULL
+
+Warning: wordwrap() expects parameter 3 to be string, resource given in %s on 
line %d
+NULL
+-- Iteration 25 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+-- Iteration 26 --
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+
+Warning: wordwrap(): Break string cannot be empty in %s on line %d
+bool(false)
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_variation4.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/wordwrap_variation4.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_variation4.phpt Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,144 @@
+--TEST--
+Test wordwrap() function : usage variations  - unexptected value for cut 
argument
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * test wordwrap() by supplying different values for cut argument
+*/
+
+echo "*** Testing wordwrap() : usage variations ***\n";
+// initialize all required variables
+$str = 'testing wordwrap function';
+$width = 10;
+$break = '<br />\n';
+
+// get an unset variable
+$unset_var = true;
+unset($unset_var);
+
+// resource variable
+$fp = fopen(__FILE__, "r");
+
+// array with different values
+$values =  array (
+
+  // integer values
+  0,
+  1,
+  12345,
+  -2345,
+
+  // float values
+  10.5,
+  -10.5,
+  10.5e10,
+  10.6E-10,
+  .5,
+
+  // array values
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => 'red', 'item' => 'pen'),
+
+  // string values
+  "string",
+  'string',
+
+  // objects
+  new stdclass(),
+
+  // empty string
+  "",
+  '',
+
+  // undefined variable
+  @$undefined_var,
+
+  // unset variable
+  @$unset_var
+);
+
+// loop though each element of the array and check the working of wordwrap()
+// when $cut arugment is supplied with different values
+echo "\n--- Testing wordwrap() by supplying different values for 'cut' 
argument ---\n";
+$counter = 1;
+for($index = 0; $index < count($values); $index ++) {
+  echo "-- Iteration $counter --\n";
+  $cut = $values [$index];
+
+  var_dump( wordwrap($str, $width, $break, $cut) );
+
+  $counter ++;
+}
+
+// close the resource
+fclose($fp);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : usage variations ***
+
+--- Testing wordwrap() by supplying different values for 'cut' argument ---
+-- Iteration 1 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 2 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 3 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 4 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 5 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 6 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 7 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 8 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 9 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 10 --
+
+Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on 
line %d
+NULL
+-- Iteration 11 --
+
+Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on 
line %d
+NULL
+-- Iteration 12 --
+
+Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on 
line %d
+NULL
+-- Iteration 13 --
+
+Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on 
line %d
+NULL
+-- Iteration 14 --
+
+Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on 
line %d
+NULL
+-- Iteration 15 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 16 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 17 --
+
+Warning: wordwrap() expects parameter 4 to be boolean, object given in %s on 
line %d
+NULL
+-- Iteration 18 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 19 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 20 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- Iteration 21 --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_variation5.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/wordwrap_variation5.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_variation5.phpt Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,60 @@
+--TEST--
+Test wordwrap() function : usage variations  - valid break arguments(spaces)
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ *test wordwrap() with break arguments as single spaces
+*/
+
+echo "*** Testing wordwrap() : usage variations ***\n";
+
+// Initialize all required variables
+$str = "Testing wordrap function";
+$width = 1;
+$cut = false;
+
+echo "\n-- Testing wordwrap() with default break value and single space as 
value --\n";
+echo "-- with default break and cut value --\n";
+var_dump( wordwrap($str, $width) );  // default break and cut value
+
+echo "-- with default cut value --\n";
+$break = ' ';
+$break1 = "  ";
+var_dump( wordwrap($str, $width, $break) );
+var_dump( wordwrap($str, $width, $break1) );
+
+echo "-- with cut value as false --\n";
+$cut = false;
+var_dump( wordwrap($str, $width, $break, $cut) );
+var_dump( wordwrap($str, $width, $break1, $cut) );
+
+echo "-- with cut value as true --\n";
+$cut = true;
+var_dump( wordwrap($str, $width, $break, $cut) );
+var_dump( wordwrap($str, $width, $break1, $cut) );
+  
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : usage variations ***
+
+-- Testing wordwrap() with default break value and single space as value --
+-- with default break and cut value --
+string(24) "Testing
+wordrap
+function"
+-- with default cut value --
+string(24) "Testing wordrap function"
+string(26) "Testing  wordrap  function"
+-- with cut value as false --
+string(24) "Testing wordrap function"
+string(26) "Testing  wordrap  function"
+-- with cut value as true --
+string(43) "T e s t i n g w o r d r a p f u n c t i o n"
+string(64) "T  e  s  t  i  n  g  w  o  r  d  r  a  p  f  u  n  c  t  i  o  n"
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/wordwrap_basic.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_basic.phpt      Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,47 @@
+--TEST--
+Test wordwrap() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing wordwrap() : basic functionality ***\n";
+
+// Initialize all required variables
+$str = "The quick brown foooooooooox jummmmmmmmmmmmped over the lazzzzzzzzzzzy 
doooooooooooooooooooooog.";
+$width = 80;
+$break = '<br />\n';
+
+// Calling wordwrap() with default arguments
+var_dump( wordwrap($str) );
+
+// Calling wordwrap() with all possible optional arguments
+// with $width arg
+var_dump( wordwrap($str, $width) );
+// with $break arg
+var_dump( wordwrap($str, $width, $break) );
+
+// Calling wordwrap() with all arguments
+// $cut as true
+$width = 10;
+$cut = true;
+var_dump( wordwrap($str, $width, $break, $cut) );
+
+// $cut as false
+$width = 10;
+$cut = false;
+var_dump( wordwrap($str, $width, $break, $cut) );
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : basic functionality ***
+string(96) "The quick brown foooooooooox jummmmmmmmmmmmped over the 
lazzzzzzzzzzzy
+doooooooooooooooooooooog."
+string(96) "The quick brown foooooooooox jummmmmmmmmmmmped over the 
lazzzzzzzzzzzy
+doooooooooooooooooooooog."
+string(103) "The quick brown foooooooooox jummmmmmmmmmmmped over the 
lazzzzzzzzzzzy<br />\ndoooooooooooooooooooooog."
+string(178) "The quick<br />\nbrown<br />\nfooooooooo<br />\nox<br 
/>\njummmmmmmm<br />\nmmmmped<br />\nover the<br />\nlazzzzzzzz<br />\nzzzy<br 
/>\ndooooooooo<br />\noooooooooo<br />\nooog."
+string(138) "The quick<br />\nbrown<br />\nfoooooooooox<br 
/>\njummmmmmmmmmmmped<br />\nover the<br />\nlazzzzzzzzzzzy<br 
/>\ndoooooooooooooooooooooog."
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/wordwrap_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/wordwrap_error.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/wordwrap_error.phpt:1.2
--- /dev/null   Fri Sep 14 19:09:11 2007
+++ php-src/ext/standard/tests/strings/wordwrap_error.phpt      Fri Sep 14 
19:09:11 2007
@@ -0,0 +1,78 @@
+--TEST--
+Test wordwrap() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : string wordwrap ( string $str [, int $width [, string $break 
[, bool $cut]]] )
+ * Description: Wraps buffer to selected number of characters using string 
break char
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing wordwrap() : error conditions ***\n";
+
+// Zero argument
+echo "\n-- Testing wordwrap() function with Zero arguments --\n";
+var_dump( wordwrap() );
+
+// More than expected number of arguments
+echo "\n-- Testing wordwrap() function with more than expected no. of 
arguments --\n";
+$str = 'testing wordwrap function';
+$width = 10;
+$break = '<br />\n';
+$cut = true;
+$extra_arg = "extra_arg";
+
+var_dump( wordwrap($str, $width, $break, $cut, $extra_arg) );
+
+// $width arg as negative value
+echo "\n-- Testing wordwrap() function with negative/zero value for width 
argument --\n";
+echo "-- width = 0 & cut = false --\n";
+// width as zero and cut as false
+$width = 0;
+$cut = false;
+var_dump( wordwrap($str, $width, $break, $cut) );
+
+echo "-- width = 0 & cut = true --\n";
+// width as zero and cut as true 
+$width = 0;
+$cut = true;
+var_dump( wordwrap($str, $width, $break, $cut) );
+
+echo "-- width = -10 & cut = false --\n";
+// width as -ne and cut as false
+$width = -10;
+$cut = false;
+var_dump( wordwrap($str, $width, $break, $cut) );
+
+echo "-- width = -10 & cut = true --\n";
+// width as -ne and cut as true 
+$width = -10;
+$cut = true;
+var_dump( wordwrap($str, $width, $break, $cut) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing wordwrap() : error conditions ***
+
+-- Testing wordwrap() function with Zero arguments --
+
+Warning: wordwrap() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing wordwrap() function with more than expected no. of arguments --
+
+Warning: wordwrap() expects at most 4 parameters, 5 given in %s on line %d
+NULL
+
+-- Testing wordwrap() function with negative/zero value for width argument --
+-- width = 0 & cut = false --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- width = 0 & cut = true --
+
+Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
+bool(false)
+-- width = -10 & cut = false --
+string(39) "testing<br />\nwordwrap<br />\nfunction"
+-- width = -10 & cut = true --
+string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br 
/>\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br 
/>\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br 
/>\nn"
+Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to