summaryrefslogtreecommitdiff
path: root/t/test-custodian-util-bytemark.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-23 15:06:49 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-23 15:06:49 +0000
commit2d3854b37b08f6da3d3e1ddcd584a1b572dc7906 (patch)
tree75f6ad82852960df378c8e0d6c0239aca29635b4 /t/test-custodian-util-bytemark.rb
parentb56f5f1bf71e8d9c773fe9bc4ff6426308e7ef1a (diff)
Moved the code to detect whether an IP-address is inside/outside the Bytemark range into its own class & added _simple_ test-cases.
Diffstat (limited to 't/test-custodian-util-bytemark.rb')
-rwxr-xr-xt/test-custodian-util-bytemark.rb65
1 files changed, 65 insertions, 0 deletions
diff --git a/t/test-custodian-util-bytemark.rb b/t/test-custodian-util-bytemark.rb
new file mode 100755
index 0000000..95222f0
--- /dev/null
+++ b/t/test-custodian-util-bytemark.rb
@@ -0,0 +1,65 @@
+#!/usr/bin/ruby1.8 -I./lib/ -I../lib/
+
+
+require 'custodian/util/bytemark'
+require 'test/unit'
+
+
+
+#
+# Unit test for our Bytemark utility class.
+#
+#
+class TestBytemarkUtil < Test::Unit::TestCase
+
+ #
+ # Create the test suite environment: NOP.
+ #
+ def setup
+ end
+
+ #
+ # Destroy the test suite environment: NOP.
+ #
+ def teardown
+ end
+
+
+ #
+ # Test that we receive sensible results from the static inside? method
+ #
+ def test_ranges
+
+ #
+ # Hash of hostnames and the expected result.
+ #
+ 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|
+
+ if ( inside )
+ assert( Custodian::Util::Bytemark.inside?( name ) == true )
+ else
+ assert( Custodian::Util::Bytemark.inside?( name ) == false )
+ end
+ end
+
+ end
+
+
+end