1--TEST--
2Test imagecolorallocate() function : usage variations  - passing RED, GREEN, BLUE values more than 255
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7if(!function_exists('imagecreatetruecolor')) {
8    die('skip imagecreatetruecolor function is not available');
9}
10?>
11--FILE--
12<?php
13require  __DIR__ . '/func.inc';
14
15echo "*** Testing imagecolorallocate() : usage variations ***\n";
16
17$values = array(
18      //Decimal integera data
19      "Decimal 256" => 256,
20
21      // octal integer data
22      "Octal 0400" => 0400,
23
24      // hexa-decimal integer data
25      "Hexa-decimal 0x100" => 0x100
26);
27
28// loop through each element of the array for blue
29foreach($values as $key => $value) {
30      echo "\n--$key--\n";
31      //Need to be created every time to get expected return value
32      $im_palette = imagecreate(200, 200);
33      $im_true_color = imagecreatetruecolor(200, 200);
34
35      trycatch_dump(
36          fn() => imagecolorallocate($im_palette, $value, 0, 0),
37          fn() => imagecolorallocate($im_true_color, $value, 0, 0),
38          fn() => imagecolorallocate($im_palette, 0, $value, 0),
39          fn() => imagecolorallocate($im_true_color, 0, $value, 0),
40          fn() => imagecolorallocate($im_palette, 0, 0, $value),
41          fn() => imagecolorallocate($im_true_color, 0, 0, $value)
42      );
43};
44?>
45--EXPECT--
46*** Testing imagecolorallocate() : usage variations ***
47
48--Decimal 256--
49!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive)
50!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive)
51!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive)
52!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive)
53!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive)
54!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive)
55
56--Octal 0400--
57!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive)
58!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive)
59!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive)
60!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive)
61!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive)
62!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive)
63
64--Hexa-decimal 0x100--
65!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive)
66!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive)
67!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive)
68!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive)
69!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive)
70!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive)
71