aboutsummaryrefslogtreecommitdiffstats
path: root/tests/network
diff options
context:
space:
mode:
Diffstat (limited to 'tests/network')
-rw-r--r--tests/network/all_tests.php2
-rw-r--r--tests/network/inet_ntop_pton.php42
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/network/all_tests.php b/tests/network/all_tests.php
index 6305aae5b8..fd36009f4c 100644
--- a/tests/network/all_tests.php
+++ b/tests/network/all_tests.php
@@ -16,6 +16,7 @@ require_once 'test_framework/framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'network/checkdnsrr.php';
+require_once 'network/inet_ntop_pton.php';
require_once 'network/ip_normalise.php';
class phpbb_network_all_tests
@@ -30,6 +31,7 @@ class phpbb_network_all_tests
$suite = new PHPUnit_Framework_TestSuite('phpBB Network Functions');
$suite->addTestSuite('phpbb_network_checkdnsrr_test');
+ $suite->addTestSuite('phpbb_network_inet_ntop_pton_test');
$suite->addTestSuite('phpbb_network_ip_normalise_test');
return $suite;
diff --git a/tests/network/inet_ntop_pton.php b/tests/network/inet_ntop_pton.php
new file mode 100644
index 0000000000..47fa0552da
--- /dev/null
+++ b/tests/network/inet_ntop_pton.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/functions.php';
+
+class phpbb_network_inet_ntop_pton_test extends phpbb_test_case
+{
+ public function data_provider()
+ {
+ return array(
+ array('127.0.0.1', '7f000001'),
+ array('192.232.131.223', 'c0e883df'),
+
+ array('::1', '00000000000000000000000000000001'),
+ array('2001:280:0:10::5', '20010280000000100000000000000005'),
+ array('fe80::200:4cff:fefe:172f', 'fe8000000000000002004cfffefe172f'),
+ );
+ }
+
+ /**
+ * @dataProvider data_provider
+ */
+ public function test_inet_ntop($address, $hex)
+ {
+ $this->assertEquals($address, phpbb_inet_ntop(pack('H*', $hex)));
+ }
+
+ /**
+ * @dataProvider data_provider
+ */
+ public function test_inet_pton($address, $hex)
+ {
+ $this->assertEquals($hex, bin2hex(phpbb_inet_pton($address)));
+ }
+}