1--TEST--
2Test imagecolorallocate() function : usage variations  - passing octal and hexa-decimal values
3--SKIPIF--
4<?php
5if(!extension_loaded('gd')) {
6    die('skip gd extension is not loaded');
7}
8if(!function_exists('imagecreatetruecolor')) {
9    die('skip imagecreatetruecolor function is not available');
10}
11?>
12--FILE--
13<?php
14/* Prototype  : int imagecolorallocate(resource im, int red, int green, int blue)
15 * Description:  Allocate a color for an image
16 * Source code: ext/gd/gd.c
17 */
18echo "*** Testing imagecolorallocate() : usage variations ***\n";
19
20$im = imagecreatetruecolor(200, 200);
21$red = 10;
22$green = 10;
23$blue = 10;
24
25$values = array(
26      // octal integer data
27      "Octal 000" => 000,
28      "Octal 012" => 012,
29      "Octal -012" => -012,
30      "Octal 0377" => 0377,
31
32      // hexa-decimal integer data
33      "Hexa-decimal 0x0" => 0x0,
34      "Hexa-decimal 0xA" => 0xA,
35      "Hexa-decimal -0xA" => -0xA,
36      "Hexa-decimal 0xFF" => 0xFF,
37);
38
39// loop through each element of the array for blue
40foreach($values as $key => $value) {
41      echo "\n--$key--\n";
42      var_dump( imagecolorallocate($im, $value, $green, $blue) );
43      var_dump( imagecolorallocate($im, $red, $value, $blue) );
44      var_dump( imagecolorallocate($im, $red, $green, $value) );
45};
46?>
47===DONE===
48--EXPECT--
49*** Testing imagecolorallocate() : usage variations ***
50
51--Octal 000--
52int(2570)
53int(655370)
54int(657920)
55
56--Octal 012--
57int(657930)
58int(657930)
59int(657930)
60
61--Octal -012--
62bool(false)
63int(652810)
64int(657910)
65
66--Octal 0377--
67int(16714250)
68int(720650)
69int(658175)
70
71--Hexa-decimal 0x0--
72int(2570)
73int(655370)
74int(657920)
75
76--Hexa-decimal 0xA--
77int(657930)
78int(657930)
79int(657930)
80
81--Hexa-decimal -0xA--
82bool(false)
83int(652810)
84int(657910)
85
86--Hexa-decimal 0xFF--
87int(16714250)
88int(720650)
89int(658175)
90===DONE===
91