From fdb5c2c9902557f0a3a006c7f62f2465c98513a7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 22 Jul 2010 12:03:57 +0200 Subject: [ticket/9746] Adding unit tests for inet_ntop() and inet_pton(). PHPBB3-9746 --- tests/network/all_tests.php | 2 ++ tests/network/inet_ntop_pton.php | 42 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/network/inet_ntop_pton.php (limited to 'tests') 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 @@ +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))); + } +} -- cgit v1.2.1