From ec4949b848522a1e71ccdfbd186ffc03fc9be328 Mon Sep 17 00:00:00 2001
From: Christian A. Weber
Date: Mon, 1 Feb 2016 14:50:58 +0100
Subject: new function it::cidr_match($ip, $cidr)

---
 tests/it.t | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'tests')

diff --git a/tests/it.t b/tests/it.t
index 33a6c13..b5b7705 100755
--- a/tests/it.t
+++ b/tests/it.t
@@ -315,6 +315,16 @@ is(it::grep('match', array('foo' => 'match', 'bar' => 'gna')), array('foo' => 'm
 setlocale(LC_CTYPE, $oldlocale);
 ini_set('default_charset', $oldcharset);	# end of tests that must run with specific charset
 
+# it::cidr_match tests
+is(it::cidr_match('192.168.2.3', '192.168.2.5/32'),					false,	"cidr_match full IP no match");
+is(it::cidr_match('192.168.2.5', '192.168.2.5/32'),					true,	"cidr_match full IP match");
+is(it::cidr_match('192.168.1.1', '192.168.42.0/24'),					false,	"cidr_match no match");
+is(it::cidr_match('192.168.42.1', '192.168.42.0/24'),					true,	"cidr_match basic match");
+is(it::cidr_match('192.168.42.42', '192.168.0.0/16'),					true,	"cidr_match class b");
+is(it::cidr_match('192.168.42.42', '192.168.42.64/26'),					false,	"cidr_match offset no match");
+is(it::cidr_match('192.168.42.42', '192.168.42.32/27'),					true,	"cidr_match offset");
+is(it::cidr_match('2001:918:ff83:101:798e:77c0:b722:fe56', '2001:918:ff83:101::/64'),	true,	"cidr_match ipv6");
+is(it::cidr_match('2001:918:ff83:102:798e:77c0:b722:fe56', '2001:918:ff83:101::/64'),	false,	"cidr_match ipv6 no match" );
 
 # it::filter_keys tests
 
-- 
cgit v1.2.3