wharmby         Thu Jan 22 13:27:30 2009 UTC

  Modified files:              
    /php-src/ext/gd/tests       imagecolorstotal_basic.phpt 
                                image_type_to_mime_type_variation3.phpt 
                                imagecolorallocate_variation1.phpt 
                                imagecolorallocate_error.phpt 
                                imagecolorallocate_variation5.phpt 
                                imagecolorallocate_variation2.phpt 
                                imagecolorallocate_variation4.phpt 
                                imagecolorstotal_error.phpt 
                                imagecolorallocate_variation6.phpt php.gif 
                                image_type_to_mime_type_variation4.phpt 
                                imagecolorallocate_basic.phpt 
                                imagecolorallocate_variation3.phpt 
  Log:
  New image tests. Tested on Windows, LInux and Linux 64 bit
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorstotal_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorstotal_basic.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorstotal_basic.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:29 2009
+++ php-src/ext/gd/tests/imagecolorstotal_basic.phpt    Thu Jan 22 13:27:29 2009
@@ -0,0 +1,36 @@
+--TEST--
+Test imagecolorstotal() function : basic functionality
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+
+if(!function_exists('imagecolorstotal') || 
!function_exists('imagecreatefromgif')) {
+    die('skip imagecolorstotal and imagecreatefromgif functions not available 
in this build');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : int imagecolorstotal  ( resource $image  )
+ * Description: Find out the number of colors in an image's palette
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorstotal() : basic functionality ***\n";
+
+// Get an image 
+$gif = dirname(__FILE__)."/php.gif";
+$im = imagecreatefromgif($gif);
+
+echo 'Total colors in image: ' . imagecolorstotal($im);
+
+// Free image
+imagedestroy($im);
+?>
+
+===DONE===
+--EXPECTF--
+*** Testing imagecolorstotal() : basic functionality ***
+Total colors in image: 128
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/image_type_to_mime_type_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/image_type_to_mime_type_variation3.phpt
diff -u /dev/null 
php-src/ext/gd/tests/image_type_to_mime_type_variation3.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:29 2009
+++ php-src/ext/gd/tests/image_type_to_mime_type_variation3.phpt        Thu Jan 
22 13:27:29 2009
@@ -0,0 +1,76 @@
+--TEST--
+Test image_type_to_mime_type() function : usage variations  - Pass equivalent 
imagetype constant integer values
+--FILE--
+<?php
+/* Prototype  : string image_type_to_mime_type(int imagetype)
+ * Description: Get Mime-Type for image-type returned by getimagesize, 
exif_read_data, exif_thumbnail, exif_imagetype 
+ * Source code: ext/standard/image.c
+ */
+
+echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
+
+//There are 17 imagetypes
+$number_of_imagetypes = 17;
+
+$iterator = 1;
+for($imagetype = 1; $imagetype<=$number_of_imagetypes; $imagetype++) {
+  echo "\n-- Iteration $iterator --\n";
+  var_dump( image_type_to_mime_type($imagetype) );
+  $iterator++;
+}
+?>
+===DONE===
+--EXPECTREGEX--
+\*\*\* Testing image_type_to_mime_type\(\) : usage variations \*\*\*
+
+-- Iteration 1 --
+unicode\(9\) "image\/gif"
+
+-- Iteration 2 --
+unicode\(10\) "image\/jpeg"
+
+-- Iteration 3 --
+unicode\(9\) "image\/png"
+
+-- Iteration 4 --
+unicode\(29\) "application\/x-shockwave-flash"
+
+-- Iteration 5 --
+unicode\(9\) "image\/psd"
+
+-- Iteration 6 --
+unicode\(9\) "image\/bmp"
+
+-- Iteration 7 --
+unicode\(10\) "image\/tiff"
+
+-- Iteration 8 --
+unicode\(10\) "image\/tiff"
+
+-- Iteration 9 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 10 --
+unicode\(9\) "image\/jp2"
+
+-- Iteration 11 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 12 --
+unicode\(24\) "application\/octet-stream"
+
+-- Iteration 13 --
+unicode\(2[49]\) "application\/(x-shockwave-flash|octet-stream)"
+
+-- Iteration 14 --
+unicode\(9\) "image\/iff"
+
+-- Iteration 15 --
+unicode\(18\) "image\/vnd.wap.wbmp"
+
+-- Iteration 16 --
+unicode\(9\) "image\/xbm"
+
+-- Iteration 17 --
+unicode\(24\) "image\/vnd.microsoft.icon"
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_variation1.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_variation1.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:29 2009
+++ php-src/ext/gd/tests/imagecolorallocate_variation1.phpt     Thu Jan 22 
13:27:29 2009
@@ -0,0 +1,267 @@
+--TEST--
+Test imagecolorallocate() function : usage variations  - passing different 
data types to first argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+// Initialise function arguments not being substituted (if any)
+$red = 10;
+$green = 10;
+$blue = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+
+// define some classes
+class classWithToString
+{
+        public function __toString() {
+                return "Class A object";
+        }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -12345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 10.1234567e10' => 10.1234567e10,
+      'float 10.7654321E-10' => 10.7654321E-10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+         'nested arrays' => array('foo', $index_array, $assoc_array),
+      
+      // null data
+         'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //resource 
+      "file resource" => $fp
+);
+
+// loop through each element of the array for im
+foreach($values as $key => $value) {
+      echo "\n-- $key --\n";
+      var_dump( imagecolorallocate($value, $red, $green, $blue) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+-- int 0 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer 
given in %s on line %d
+NULL
+
+-- int 1 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer 
given in %s on line %d
+NULL
+
+-- int 12345 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer 
given in %s on line %d
+NULL
+
+-- int -12345 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, integer 
given in %s on line %d
+NULL
+
+-- float 10.5 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given 
in %s on line %d
+NULL
+
+-- float -10.5 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given 
in %s on line %d
+NULL
+
+-- float 10.1234567e10 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given 
in %s on line %d
+NULL
+
+-- float 10.7654321E-10 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given 
in %s on line %d
+NULL
+
+-- float .5 --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, double given 
in %s on line %d
+NULL
+
+-- empty array --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given 
in %s on line %d
+NULL
+
+-- int indexed array --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given 
in %s on line %d
+NULL
+
+-- associative array --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given 
in %s on line %d
+NULL
+
+-- nested arrays --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, array given 
in %s on line %d
+NULL
+
+-- uppercase NULL --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given 
in %s on line %d
+NULL
+
+-- lowercase null --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given 
in %s on line %d
+NULL
+
+-- lowercase true --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean 
given in %s on line %d
+NULL
+
+-- lowercase false --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean 
given in %s on line %d
+NULL
+
+-- uppercase TRUE --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean 
given in %s on line %d
+NULL
+
+-- uppercase FALSE --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, boolean 
given in %s on line %d
+NULL
+
+-- empty string DQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, Unicode 
string given in %s on line %d
+NULL
+
+-- empty string SQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, Unicode 
string given in %s on line %d
+NULL
+
+-- string DQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, Unicode 
string given in %s on line %d
+NULL
+
+-- string SQ --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, Unicode 
string given in %s on line %d
+NULL
+
+-- mixed case string --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, Unicode 
string given in %s on line %d
+NULL
+
+-- heredoc --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, Unicode 
string given in %s on line %d
+NULL
+
+-- instance of classWithToString --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, object given 
in %s on line %d
+NULL
+
+-- instance of classWithoutToString --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, object given 
in %s on line %d
+NULL
+
+-- undefined var --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given 
in %s on line %d
+NULL
+
+-- unset var --
+
+Warning: imagecolorallocate() expects parameter 1 to be resource, null given 
in %s on line %d
+NULL
+
+-- file resource --
+
+Warning: imagecolorallocate(): supplied resource is not a valid Image resource 
in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_error.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_error.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:29 2009
+++ php-src/ext/gd/tests/imagecolorallocate_error.phpt  Thu Jan 22 13:27:29 2009
@@ -0,0 +1,49 @@
+--TEST--
+Test imagecolorallocate() function : error conditions 
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+$red = 10;
+$green = 10;
+$blue = 10;
+$extra_arg = 10;
+$im = imagecreate(200, 200);
+
+echo "*** Testing imagecolorallocate() : error conditions ***\n";
+
+//Test imagecolorallocate with one more than the expected number of arguments
+echo "\n-- Testing imagecolorallocate() function with more than expected no. 
of arguments --\n";
+var_dump( imagecolorallocate($im, $red, $green, $blue, $extra_arg) );
+
+// Testing imagecolorallocate with one less than the expected number of 
arguments
+echo "\n-- Testing imagecolorallocate() function with less than expected no. 
of arguments --\n";
+var_dump( imagecolorallocate() );
+var_dump( imagecolorallocate($im, $red, $green) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : error conditions ***
+
+-- Testing imagecolorallocate() function with more than expected no. of 
arguments --
+
+Warning: imagecolorallocate() expects exactly 4 parameters, 5 given in %s on 
line %d
+NULL
+
+-- Testing imagecolorallocate() function with less than expected no. of 
arguments --
+
+Warning: imagecolorallocate() expects exactly 4 parameters, 0 given in %s on 
line %d
+NULL
+
+Warning: imagecolorallocate() expects exactly 4 parameters, 3 given in %s on 
line %d
+NULL
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_variation5.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_variation5.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorallocate_variation5.phpt     Thu Jan 22 
13:27:29 2009
@@ -0,0 +1,90 @@
+--TEST--
+Test imagecolorallocate() function : usage variations  - passing octal and 
hexa-decimal values
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+    die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description:  Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$red = 10;
+$green = 10;
+$blue = 10;
+
+$values = array(
+      // octal integer data
+      "Octal 000" => 000,
+      "Octal 012" => 012,
+      "Octal -012" => -012,
+      "Octal 0377" => 0377,
+     
+      // hexa-decimal integer data
+      "Hexa-decimal 0x0" => 0x0,
+      "Hexa-decimal 0xA" => 0xA,
+      "Hexa-decimal -0xA" => -0xA,
+      "Hexa-decimal 0xFF" => 0xFF,
+);
+
+// loop through each element of the array for blue
+foreach($values as $key => $value) {
+      echo "\n--$key--\n";
+      var_dump( imagecolorallocate($im, $value, $green, $blue) );
+      var_dump( imagecolorallocate($im, $red, $value, $blue) );
+      var_dump( imagecolorallocate($im, $red, $green, $value) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--Octal 000--
+int(2570)
+int(655370)
+int(657920)
+
+--Octal 012--
+int(657930)
+int(657930)
+int(657930)
+
+--Octal -012--
+bool(false)
+int(652810)
+int(657910)
+
+--Octal 0377--
+int(16714250)
+int(720650)
+int(658175)
+
+--Hexa-decimal 0x0--
+int(2570)
+int(655370)
+int(657920)
+
+--Hexa-decimal 0xA--
+int(657930)
+int(657930)
+int(657930)
+
+--Hexa-decimal -0xA--
+bool(false)
+int(652810)
+int(657910)
+
+--Hexa-decimal 0xFF--
+int(16714250)
+int(720650)
+int(658175)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_variation2.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_variation2.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorallocate_variation2.phpt     Thu Jan 22 
13:27:29 2009
@@ -0,0 +1,214 @@
+--TEST--
+Test imagecolorallocate() function : usage variations  - passing different 
data types to second argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+    die('skip imagecreatetruecolor function is not available');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$green = 10;
+$blue = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+// define some classes
+class classWithToString
+{
+        public function __toString() {
+                return "Class A object";
+        }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 10.1234567e10' => 10.1234567e10,
+      'float 10.7654321E-10' => 10.7654321E-10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+         'nested arrays' => array('foo', $index_array, $assoc_array),
+      
+      // null data
+         'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //resource 
+      "file resource" => $fp
+);
+// loop through each element of the array for red
+foreach($values as $key => $value) {
+      echo "\n--$key--\n";
+      var_dump( imagecolorallocate($im, $value, $green, $blue) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--float 10.5--
+int(657930)
+
+--float -10.5--
+bool(false)
+
+--float 10.1234567e10--
+bool(false)
+
+--float 10.7654321E-10--
+int(2570)
+
+--float .5--
+int(2570)
+
+--empty array--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in 
%s on line %d
+NULL
+
+--int indexed array--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in 
%s on line %d
+NULL
+
+--associative array--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in 
%s on line %d
+NULL
+
+--nested arrays--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, array given in 
%s on line %d
+NULL
+
+--uppercase NULL--
+int(2570)
+
+--lowercase null--
+int(2570)
+
+--lowercase true--
+int(68106)
+
+--lowercase false--
+int(2570)
+
+--uppercase TRUE--
+int(68106)
+
+--uppercase FALSE--
+int(2570)
+
+--empty string DQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--empty string SQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--string DQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--string SQ--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--mixed case string--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--heredoc--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--instance of classWithToString--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, object given in 
%s on line %d
+NULL
+
+--instance of classWithoutToString--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, object given in 
%s on line %d
+NULL
+
+--undefined var--
+int(2570)
+
+--unset var--
+int(2570)
+
+--file resource--
+
+Warning: imagecolorallocate() expects parameter 2 to be long, resource given 
in %s on line %d
+NULL
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_variation4.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_variation4.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorallocate_variation4.phpt     Thu Jan 22 
13:27:29 2009
@@ -0,0 +1,214 @@
+--TEST--
+Test imagecolorallocate() function : usage variations  - passing different 
data types to fourth argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+    die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description:  Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$red = 10;
+$green = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+// define some classes
+class classWithToString
+{
+        public function __toString() {
+                return "Class A object";
+        }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 10.1234567e10' => 10.1234567e10,
+      'float 10.7654321E-10' => 10.7654321E-10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+         'nested arrays' => array('foo', $index_array, $assoc_array),
+      
+      // null data
+         'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //resource 
+      "file resource" => $fp
+);
+// loop through each element of the array for red
+foreach($values as $key => $value) {
+      echo "\n--$key--\n";
+      var_dump( imagecolorallocate($im, $red, $green, $value) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--float 10.5--
+int(657930)
+
+--float -10.5--
+int(657910)
+
+--float 10.1234567e10--
+bool(false)
+
+--float 10.7654321E-10--
+int(657920)
+
+--float .5--
+int(657920)
+
+--empty array--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in 
%s on line %d
+NULL
+
+--int indexed array--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in 
%s on line %d
+NULL
+
+--associative array--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in 
%s on line %d
+NULL
+
+--nested arrays--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, array given in 
%s on line %d
+NULL
+
+--uppercase NULL--
+int(657920)
+
+--lowercase null--
+int(657920)
+
+--lowercase true--
+int(657921)
+
+--lowercase false--
+int(657920)
+
+--uppercase TRUE--
+int(657921)
+
+--uppercase FALSE--
+int(657920)
+
+--empty string DQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--empty string SQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--string DQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--string SQ--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--mixed case string--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--heredoc--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, Unicode string 
given in %s on line %d
+NULL
+
+--instance of classWithToString--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, object given in 
%s on line %d
+NULL
+
+--instance of classWithoutToString--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, object given in 
%s on line %d
+NULL
+
+--undefined var--
+int(657920)
+
+--unset var--
+int(657920)
+
+--file resource--
+
+Warning: imagecolorallocate() expects parameter 4 to be long, resource given 
in %s on line %d
+NULL
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorstotal_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorstotal_error.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorstotal_error.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorstotal_error.phpt    Thu Jan 22 13:27:29 2009
@@ -0,0 +1,54 @@
+--TEST--
+Test imagecolorstotal() function : error conditions  - Pass incorrect number 
of arguments
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecolorstotal')) {
+    die('skip imagecolorstotal function is not available');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : int imagecolorstotal  ( resource $image  )
+ * Description: Find out the number of colors in an image's palette
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorstotal() : error conditions ***\n";
+
+// Get a resource
+$im = fopen(__FILE__, 'r');
+
+echo "\n-- Testing imagecolorstotal() function with Zero arguments --\n";
+var_dump( imagecolorstotal() );
+
+echo "\n-- Testing imagecolorstotal() function with more than expected no. of 
arguments --\n";
+$extra_arg = false;
+var_dump( imagecolorstotal($im, $extra_arg) );
+
+echo "\n-- Testing imagecolorstotal() function with a invalid resource\n";
+var_dump( imagecolorstotal($im) );
+
+fclose($im); 
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorstotal() : error conditions ***
+
+-- Testing imagecolorstotal() function with Zero arguments --
+
+Warning: imagecolorstotal() expects exactly 1 parameter, 0 given in %s on line 
%d
+NULL
+
+-- Testing imagecolorstotal() function with more than expected no. of 
arguments --
+
+Warning: imagecolorstotal() expects exactly 1 parameter, 2 given in %s on line 
%d
+NULL
+
+-- Testing imagecolorstotal() function with a invalid resource
+
+Warning: imagecolorstotal(): supplied resource is not a valid Image resource 
in %s on line %d
+bool(false)
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_variation6.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_variation6.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorallocate_variation6.phpt     Thu Jan 22 
13:27:29 2009
@@ -0,0 +1,56 @@
+--TEST--
+Test imagecolorallocate() function : usage variations  - passing RED, GREEN, 
BLUE values more than 255
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+    die('skip imagecreatetruecolor function is not available');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description:  Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$values = array(
+      //Decimal integera data  
+      "Decimal 256" => 256,
+      
+      // octal integer data
+      "Octal 0400" => 0400,
+     
+      // hexa-decimal integer data
+      "Hexa-decimal 0x100" => 0x100
+);
+
+// loop through each element of the array for blue
+foreach($values as $key => $value) {
+      echo "\n--$key--\n";
+      //Need to be created every time to get expected return value
+      $im_palette = imagecreate(200, 200);
+      $im_true_color = imagecreatetruecolor(200, 200);
+      var_dump( imagecolorallocate($im_palette, $value, $value, $value) );
+      var_dump( imagecolorallocate($im_true_color, $value, $value, $value) );
+};
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : usage variations ***
+
+--Decimal 256--
+int(0)
+int(16843008)
+
+--Octal 0400--
+int(0)
+int(16843008)
+
+--Hexa-decimal 0x100--
+int(0)
+int(16843008)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/php.gif?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/php.gif
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/image_type_to_mime_type_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/image_type_to_mime_type_variation4.phpt
diff -u /dev/null 
php-src/ext/gd/tests/image_type_to_mime_type_variation4.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/image_type_to_mime_type_variation4.phpt        Thu Jan 
22 13:27:29 2009
@@ -0,0 +1,29 @@
+--TEST--
+Test image_type_to_mime_type() function : usage variations - Passing 
IMAGETYPE_ICO and IMAGETYPE_SWC
+--SKIPIF--
+<?php
+       if (!extension_loaded('zlib')) {
+               die("skip zlib extension is not available");
+       }
+?>
+--FILE--
+<?php
+/* Prototype  : string image_type_to_mime_type(int imagetype)
+ * Description: Get Mime-Type for image-type returned by getimagesize, 
exif_read_data, exif_thumbnail, exif_imagetype 
+ * Source code: ext/standard/image.c
+ */
+
+
+echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
+
+error_reporting(E_ALL ^ E_NOTICE);
+
+var_dump( image_type_to_mime_type(IMAGETYPE_ICO) );
+var_dump( image_type_to_mime_type(IMAGETYPE_SWC) );
+?>
+===DONE===
+--EXPECT--
+*** Testing image_type_to_mime_type() : usage variations ***
+unicode(24) "image/vnd.microsoft.icon"
+unicode(29) "application/x-shockwave-flash"
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_basic.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_basic.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorallocate_basic.phpt  Thu Jan 22 13:27:29 2009
@@ -0,0 +1,35 @@
+--TEST--
+Test imagecolorallocate() function : basic functionality
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+    die('skip imagecreatetruecolor function is not available');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : int imagecolorallocate(resource im, int red, int green, int 
blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : basic functionality ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+// Calling imagecolorallocate() with all possible arguments
+var_dump( imagecolorallocate($im, 255, 0, 0) );
+var_dump( imagecolorallocate($im, 0, 255, 0) );
+var_dump( imagecolorallocate($im, 0, 0, 255) );
+var_dump( imagecolorallocate($im, 255, 255, 255) );
+?>
+===DONE===
+--EXPECTF--
+*** Testing imagecolorallocate() : basic functionality ***
+int(16711680)
+int(65280)
+int(255)
+int(16777215)
+===DONE===
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagecolorallocate_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/imagecolorallocate_variation3.phpt
diff -u /dev/null php-src/ext/gd/tests/imagecolorallocate_variation3.phpt:1.2
--- /dev/null   Thu Jan 22 13:27:30 2009
+++ php-src/ext/gd/tests/imagecolorallocate_variation3.phpt     Thu Jan 22 
13:27:29 2009
@@ -0,0 +1,214 @@
+--TEST--
+Test imagecolorallocate() function : usage variations  - passing different 
data types to third argument
+--SKIPIF--
+<?php
+if(!extension_loaded('gd')) {
+    die('skip gd extension is not loaded');
+}
+if(!function_exists('imagecreatetruecolor')) {
+    die('skip imagecreatetruecolor function is not available');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : imagecolorallocate(resource im, int red, int green, int blue)
+ * Description: Allocate a color for an image
+ * Source code: ext/gd/gd.c
+ */
+
+echo "*** Testing imagecolorallocate() : usage variations ***\n";
+
+$im = imagecreatetruecolor(200, 200);
+$red = 10;
+$blue = 10;
+
+$fp = tmpfile();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+// define some classes
+class classWithToString
+{
+        public function __toString() {
+                return "Class A object";
+        }
+}
+
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$values = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 10.1234567e10' => 10.1234567e10,
+      'float 10.7654321E-10' => 10.7654321E-10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+         'nested arrays' => array('foo', $index_array, $assoc_array),
+      
+      // null data
+         'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //resource 
+      "file resource" => $fp
+);
+// loop through each element of the array for red
+foreach($values as $key => $value) {
+      echo "\n--$key--\n";
+      var_dump( imagecolorallocate($im, $red, $value, $blue) );
+};
+?>
+===DONE===
+--EXPECTREGEX--
+\*\*\* Testing imagecolorallocate\(\) : usage variations \*\*\*
+
+--float 10.5--
+int\(657930\)
+
+--float -10.5--
+int\(652810\)
+
+--float 10.1234567e10--
+int\(655114\)|int\(217143306\)
+
+--float 10.7654321E-10--
+int\(655370\)
+
+--float .5--
+int\(655370\)
+
+--empty array--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, array given in 
(\w*|\/|\.)* on line \d+
+NULL
+
+--int indexed array--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, array given in 
(\w*|\/|\.)* on line \d+
+NULL
+
+--associative array--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, array given in 
(\w*|\/|\.)* on line \d+
+NULL
+
+--nested arrays--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, array given in 
(\w*|\/|\.)* on line \d+
+NULL
+
+--uppercase NULL--
+int\(655370\)
+
+--lowercase null--
+int\(655370\)
+
+--lowercase true--
+int\(655626\)
+
+--lowercase false--
+int\(655370\)
+
+--uppercase TRUE--
+int\(655626\)
+
+--uppercase FALSE--
+int\(655370\)
+
+--empty string DQ--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, Unicode string 
given in (\w*|\/|\.)* on line \d+
+NULL
+
+--empty string SQ--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, Unicode string 
given in (\w*|\/|\.)* on line \d+
+NULL
+
+--string DQ--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, Unicode string 
given in (\w*|\/|\.)* on line \d+
+NULL
+
+--string SQ--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, Unicode string 
given in (\w*|\/|\.)* on line \d+
+NULL
+
+--mixed case string--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, Unicode string 
given in (\w*|\/|\.)* on line \d+
+NULL
+
+--heredoc--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, Unicode string 
given in (\w*|\/|\.)* on line \d+
+NULL
+
+--instance of classWithToString--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, object given 
in (\w*|\/|\.)* on line \d+
+NULL
+
+--instance of classWithoutToString--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, object given 
in (\w*|\/|\.)* on line \d+
+NULL
+
+--undefined var--
+int\(655370\)
+
+--unset var--
+int\(655370\)
+
+--file resource--
+
+Warning: imagecolorallocate\(\) expects parameter 3 to be long, resource given 
in (\w*|\/|\.)* on line \d+
+NULL
+===DONE===
\ No newline at end of file

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

Reply via email to