summaryrefslogtreecommitdiff
path: root/ext/gd/tests
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
commit2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch)
tree41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/gd/tests
parentd29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff)
downloadphp-upstream/5.2.2.tar.gz
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/gd/tests')
-rw-r--r--ext/gd/tests/bug37360.phpt3
-rw-r--r--ext/gd/tests/bug38179.phpt2
-rw-r--r--ext/gd/tests/bug38212.phpt5
-rw-r--r--ext/gd/tests/bug39273.phpt32
-rw-r--r--ext/gd/tests/bug39286.phpt14
-rw-r--r--ext/gd/tests/bug39366.phpt21
-rw-r--r--ext/gd/tests/bug39508.phpt16
-rw-r--r--ext/gd/tests/bug39780.phpt21
-rw-r--r--ext/gd/tests/bug39780.pngbin0 -> 393216 bytes
-rw-r--r--ext/gd/tests/bug40764.phpt31
-rw-r--r--ext/gd/tests/createfromwbmp2.phpt47
-rw-r--r--ext/gd/tests/gif.phpt3
-rw-r--r--ext/gd/tests/test_gif_2.gifbin33641 -> 0 bytes
13 files changed, 190 insertions, 5 deletions
diff --git a/ext/gd/tests/bug37360.phpt b/ext/gd/tests/bug37360.phpt
index dce22e7c6..4b377ade8 100644
--- a/ext/gd/tests/bug37360.phpt
+++ b/ext/gd/tests/bug37360.phpt
@@ -11,4 +11,5 @@ $im = imagecreatefromgif(dirname(__FILE__) . '/bug37360.gif');
var_dump($im);
?>
--EXPECTF--
-resource(%d) of type (gd)
+Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d
+bool(false)
diff --git a/ext/gd/tests/bug38179.phpt b/ext/gd/tests/bug38179.phpt
index 01adaa32c..34a6d58e0 100644
--- a/ext/gd/tests/bug38179.phpt
+++ b/ext/gd/tests/bug38179.phpt
@@ -1,5 +1,5 @@
--TEST--
-imagecopy doen't copy alpha, palette to truecolor
+Bug #38179 (imagecopy from a palette to a truecolor image loses alpha channel)
--SKIPIF--
<?php
if (!function_exists('imagecopy')) die("skip gd extension not available\n");
diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt
index 0094712a5..04c89fece 100644
--- a/ext/gd/tests/bug38212.phpt
+++ b/ext/gd/tests/bug38212.phpt
@@ -1,5 +1,5 @@
--TEST--
-imagecopy doen't copy alpha, palette to truecolor
+Bzg #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
--SKIPIF--
<?php
if (!function_exists('imagecopy')) die("skip gd extension not available\n");
@@ -14,4 +14,5 @@ $im = imagecreatefromgd2part($file, 0,0, -25,10);
unlink($file);
?>
--EXPECTF--
-Warning: imagecreatefromgd2part(): '%sbug38212.gd2' is not a valid GD2 file in %sbug38212.php on line %d
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
diff --git a/ext/gd/tests/bug39273.phpt b/ext/gd/tests/bug39273.phpt
new file mode 100644
index 000000000..438450044
--- /dev/null
+++ b/ext/gd/tests/bug39273.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #37360 (gdimagecreatefromgif, bad image sizes)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$small = imagecreatetruecolor(10, 10);
+$c1 = imagecolorallocatealpha($small, 255,0,0,50);
+imagecolortransparent($small, 0);
+imagealphablending($small, 0);
+imagefilledrectangle($small, 0,0, 6,6, $c1);
+
+$width = 300;
+$height = 300;
+$srcw = imagesx($small);
+$srch = imagesy($small);
+
+$img = imagecreatetruecolor($width, $height);
+
+imagecolortransparent($img, 0);
+imagealphablending($img, false);
+imagecopyresized($img, $small, 0,0, 0,0, $width, $height, $srcw, $srch);
+imagesavealpha($img, 1);
+
+$c = imagecolorat($img, 0,0);
+printf("%X", $c);
+?>
+--EXPECTF--
+32FF0000
diff --git a/ext/gd/tests/bug39286.phpt b/ext/gd/tests/bug39286.phpt
new file mode 100644
index 000000000..3f2a17812
--- /dev/null
+++ b/ext/gd/tests/bug39286.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #39508 (imagefill crashes with small images 3 pixels or less)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100);
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
diff --git a/ext/gd/tests/bug39366.phpt b/ext/gd/tests/bug39366.phpt
new file mode 100644
index 000000000..212012a1b
--- /dev/null
+++ b/ext/gd/tests/bug39366.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #39366 (imagerotate does not respect alpha with angles>45)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+
+$im = imagecreatetruecolor(10,10);
+imagealphablending($im, 0);
+imagefilledrectangle($im, 0,0, 8,8, 0x32FF0000);
+$rotate = imagerotate($im, 180, 0);
+imagecolortransparent($rotate,0);
+imagesavealpha($rotate, true);
+$c = imagecolorat($rotate,5,5);
+printf("%X\n", $c);
+?>
+--EXPECTF--
+32FF0000
diff --git a/ext/gd/tests/bug39508.phpt b/ext/gd/tests/bug39508.phpt
new file mode 100644
index 000000000..9e86efc20
--- /dev/null
+++ b/ext/gd/tests/bug39508.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #39508 (imagefill crashes with small images 3 pixels or less)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$im = imagecreatetruecolor(3,1);
+$bgcolor = imagecolorallocatealpha($im,255, 255, 0, 0);
+imagefill($im,0,0,$bgcolor);
+print_r(imagecolorat($im, 1,0));
+?>
+--EXPECTF--
+16776960
diff --git a/ext/gd/tests/bug39780.phpt b/ext/gd/tests/bug39780.phpt
new file mode 100644
index 000000000..3a23aa9df
--- /dev/null
+++ b/ext/gd/tests/bug39780.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #39780 (PNG image with CRC/data error raises a fatal error)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+
+$im = imagecreatefrompng(dirname(__FILE__) . '/bug39780.png');
+var_dump($im);
+?>
+--EXPECTF--
+
+Warning: imagecreatefrompng(): gd-png: fatal libpng error: IDAT: CRC error in %s on line %d
+
+Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d
+
+Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d
+bool(false)
diff --git a/ext/gd/tests/bug39780.png b/ext/gd/tests/bug39780.png
new file mode 100644
index 000000000..73a7d6a3e
--- /dev/null
+++ b/ext/gd/tests/bug39780.png
Binary files differ
diff --git a/ext/gd/tests/bug40764.phpt b/ext/gd/tests/bug40764.phpt
new file mode 100644
index 000000000..cbe262fe7
--- /dev/null
+++ b/ext/gd/tests/bug40764.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #40764 (line thickness not respected for horizontal and vertical lines)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+?>
+--FILE--
+<?php
+$image=imagecreatetruecolor(400, 400);
+$white = imagecolorallocate($image, 255, 255, 255);
+$black = imagecolorallocate($image, 0, 0, 0);
+$red = imagecolorallocate($image, 255, 0, 0);
+
+imagefill($image, 0, 0, $white);
+imagesetthickness($image, 10);
+
+imageline($image, 200, 0, 200, 400, $black);
+imageline($image, 0, 200, 400, 200, $black);
+imageline($image, 0, 0, 392, 392, $black);
+
+imagesetthickness($image, 1);
+
+imageline($image, 200, 0, 200, 400, $red);
+imageline($image, 0, 200, 400, 200, $red);
+imageline($image, 0, 0, 392, 392, $red);
+print_r(imagecolorat($image, 195, 0));
+print_r(imagecolorat($image, 0, 195));
+
+?>
+--EXPECT--
+00
diff --git a/ext/gd/tests/createfromwbmp2.phpt b/ext/gd/tests/createfromwbmp2.phpt
new file mode 100644
index 000000000..88c39b02a
--- /dev/null
+++ b/ext/gd/tests/createfromwbmp2.phpt
@@ -0,0 +1,47 @@
+--TEST--
+imagecreatefromwbmp with invalid wbmp
+--SKIPIF--
+<?php
+ if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
+?>
+--FILE--
+<?php
+$filename = dirname(__FILE__) . '/_tmp.wbmp';
+$fp = fopen($filename,"wb");
+if (!$fp) {
+ exit("Failed to create <$filename>");
+}
+
+//write header
+$c = 0;
+fputs($fp, chr($c), 1);
+fputs($fp, $c, 1);
+
+//write width = 2^32 / 4 + 1
+$c = 0x84;
+fputs($fp, chr($c), 1);
+$c = 0x80;
+fputs($fp, chr($c), 1);
+fputs($fp, chr($c), 1);
+fputs($fp, chr($c), 1);
+$c = 0x01;
+fputs($fp, chr($c), 1);
+
+/*write height = 4*/
+$c = 0x04;
+fputs($fp, chr($c), 1);
+
+/*write some data to cause overflow*/
+for ($i=0; $i<10000; $i++) {
+ fwrite($fp, chr($c), 1);
+}
+
+fclose($fp);
+$im = imagecreatefromwbmp($filename);
+unlink($filename);
+?>
+--EXPECTF--
+Warning: imagecreatefromwbmp(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
+ in %s on line %d
+
+Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d
diff --git a/ext/gd/tests/gif.phpt b/ext/gd/tests/gif.phpt
index f4ed578c4..dd71a5404 100644
--- a/ext/gd/tests/gif.phpt
+++ b/ext/gd/tests/gif.phpt
@@ -2,7 +2,7 @@
gif in/out
--SKIPIF--
<?php
-// $Id: gif.phpt,v 1.2.2.2 2006/07/17 12:54:09 pajoye Exp $
+// $Id: gif.phpt,v 1.2.2.3 2006/11/03 14:51:02 bjori Exp $
if (!extension_loaded('gd')) {
die("skip gd extension not available.");
}
@@ -133,6 +133,7 @@ if (check_box(255,255,255, 10)) {
}
@unlink($cwd . "/test_gif.gif");
+@unlink($cwd . "/test_gif_2.gif");
?>
--EXPECT--
<4 cols: ok
diff --git a/ext/gd/tests/test_gif_2.gif b/ext/gd/tests/test_gif_2.gif
deleted file mode 100644
index 332ec8b41..000000000
--- a/ext/gd/tests/test_gif_2.gif
+++ /dev/null
Binary files differ