Skip to content

Commit 2873b5b

Browse files
committed
added some tests based on bug #64395
1 parent c6b8d99 commit 2873b5b

File tree

3 files changed

+80
-7
lines changed

3 files changed

+80
-7
lines changed

ext/standard/tests/network/ip2long_variation1.phpt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
--TEST--
2-
Test ip2long() function : usage variation
3-
--SKIPIF--
4-
<?php
5-
if(substr(PHP_OS, 0, 3) == "WIN")
6-
die("skip. Windows is more compliant (like 0 for localhost, etc.)");
7-
?>
2+
Test ip2long() function : usage variation 1
83
--FILE--
94
<?php
105
/* Prototype : int ip2long(string ip_address)
@@ -201,4 +196,4 @@ bool(false)
201196
--resource--
202197
Error: 2 - ip2long() expects parameter 1 to be string, resource given, %s(%d)
203198
NULL
204-
===DONE===
199+
===DONE===
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Test ip2long() function : usage variation 2, 32 bit
3+
--SKIPIF--
4+
<?php if(PHP_INT_SIZE != 4) {die('skip 32 bit only');} ?>
5+
--FILE--
6+
<?php
7+
/* Prototype : int ip2long(string ip_address)
8+
* Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address
9+
* Source code: ext/standard/basic_functions.c
10+
* Alias to functions:
11+
*/
12+
13+
$ips = array(
14+
"1.1.011.011",
15+
"127.0.0.1",
16+
"1.1.071.071",
17+
"0.0.0.0",
18+
"1.1.081.081",
19+
"192.168.0.0",
20+
"256.0.0.1",
21+
"192.168.0xa.5",
22+
);
23+
24+
foreach($ips as $ip) {
25+
var_dump(ip2long($ip));
26+
}
27+
28+
?>
29+
===DONE===
30+
--EXPECT--
31+
bool(false)
32+
int(2130706433)
33+
bool(false)
34+
int(0)
35+
bool(false)
36+
int(-1062731776)
37+
bool(false)
38+
bool(false)
39+
===DONE===
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Test ip2long() function : usage variation 2, 64 bit
3+
--SKIPIF--
4+
<?php if(PHP_INT_SIZE != 8) {die('skip 64 bit only');} ?>
5+
--FILE--
6+
<?php
7+
/* Prototype : int ip2long(string ip_address)
8+
* Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address
9+
* Source code: ext/standard/basic_functions.c
10+
* Alias to functions:
11+
*/
12+
13+
$ips = array(
14+
"1.1.011.011",
15+
"127.0.0.1",
16+
"1.1.071.071",
17+
"0.0.0.0",
18+
"1.1.081.081",
19+
"192.168.0.0",
20+
"256.0.0.1",
21+
"192.168.0xa.5",
22+
);
23+
24+
foreach($ips as $ip) {
25+
var_dump(ip2long($ip));
26+
}
27+
28+
?>
29+
===DONE===
30+
--EXPECT--
31+
bool(false)
32+
int(2130706433)
33+
bool(false)
34+
int(0)
35+
bool(false)
36+
int(3232235520)
37+
bool(false)
38+
bool(false)
39+
===DONE===

0 commit comments

Comments
 (0)