From 1f39546155f568923149df3e3c6adcf4b2bd3169 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Tue, 20 Nov 2012 14:42:28 +0000 Subject: Moved inside_bytemark? into its own method, added trivial test-cases. --- t/test-alerter.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 't/test-alerter.rb') diff --git a/t/test-alerter.rb b/t/test-alerter.rb index 995b27b..a09c666 100755 --- a/t/test-alerter.rb +++ b/t/test-alerter.rb @@ -86,6 +86,7 @@ class TestAlerter < Test::Unit::TestCase if ( text =~ /OUTSIDE/ ) assert( inside == false ) end + end # @@ -102,4 +103,43 @@ class TestAlerter < Test::Unit::TestCase + # + # Test inside_bytemark? + # + def test_inside_bytemark + + # + # Hash of hostnames and version of address. + # + to_test = { + + # + # Hosts inside the Bytemark network + # + "80.68.85.48" => true, + "2001:41c8:125:46::10" => true, + + # + # Hosts outside the Bytemark network + # + "127.0.0.1" => false, + "192.168.1.1" => false, + "2a00:1450:400c:c00::93" => false, + } + + + to_test.each do |name,inside| + + obj = Alerter.new( nil ) + + if ( inside ) + assert( obj.inside_bytemark?( name ) == true ) + else + assert( obj.inside_bytemark?( name ) == false ) + end + end + + end + + end -- cgit v1.2.1