C0 code coverage information generated on Wed Mar 15 10:52:01 MST 2006


Marked code looks like this.
This line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this.
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
./test/test_iplib.rb 103 103
100.0% 
100.0% 
  1 require 'iplib'
  2 require 'test/unit'
  3 
  4 class TestNetwork < Test::Unit::TestCase
  5   def setup
  6     @network = Network.new("test_one", '255.255.0.0')
  7   end
  8 
  9   def test_new
 10     assert_kind_of(Network, @network)
 11     network = Network.new()
 12     assert_equal('', network.name)
 13     assert_equal('0.0.0.0/24', network.mask)
 14   end
 15 
 16   def test_mask_complement_as_string
 17     assert_equal('0.0.255.255', @network.mask_complement_as_string)
 18   end
 19 end
 20 
 21 
 22 class TestNetworkPrefix < Test::Unit::TestCase
 23   def setup
 24     @network_1 = Network.new('test_one', '255.255.254.0')
 25     @network_2 = Network.new('test_one', '255.255.0.0')
 26     @network_3 = Network.new('test_two', '255.255.254.0')
 27     @prefix_1 = NetworkPrefix.new(@network_1, :prod, :sigma, '10.72.54.0')
 28     @prefix_2 = NetworkPrefix.new(@network_1, :prod, :sigma, '255.255.255.255')
 29     @prefix_3 = NetworkPrefix.new(@network_2, :prod, :sigma, '10.72.0.0')
 30     @prefix_4 = NetworkPrefix.new(@network_2, :prod, :pi,    '10.73.0.0')
 31     @prefix_5 = NetworkPrefix.new(@network_3, :prod, :sigma, '10.72.74.0')
 32   end
 33   
 34   def test_ip
 35     assert_equal( '10.72.54.0', @prefix_1.get_ip('0.0.0.0') )
 36     assert_equal( '10.72.54.1', @prefix_1.get_ip('0.0.0.1') )
 37     assert_equal( '10.72.55.255', @prefix_1.get_ip('0.0.1.255') )
 38 
 39     # Show we ignore masked off parts of the base address      
 40     assert_equal( '10.72.55.255', @prefix_1.get_ip('255.255.255.255') )
 41     
 42     # This network prefix is bigger than the mask allows - the extra
 43     # bits will be ignored.
 44     assert_equal( '255.255.254.0', @prefix_2.get_ip('0.0.0.0') )
 45     assert_equal( '255.255.254.255', @prefix_2.get_ip('0.0.0.255') )
 46     assert_equal( '255.255.255.255', @prefix_2.get_ip('0.0.1.255') )
 47     assert_equal( '255.255.255.255', @prefix_2.get_ip('255.255.255.255') )
 48   end
 49 
 50   def test_contains_ip
 51     assert @prefix_3.contains_ip?('10.72.10.65')
 52     assert @prefix_3.contains_ip?('10.72.165.14')
 53     assert !@prefix_3.contains_ip?('10.73.1.12')
 54     assert !@prefix_3.contains_ip?('1.2.3.4')
 55 
 56     assert @prefix_4.contains_ip?('10.73.1.12')
 57     assert !@prefix_4.contains_ip?('10.72.10.65')
 58     assert !@prefix_4.contains_ip?('10.72.165.14')
 59     assert !@prefix_4.contains_ip?('1.2.3.4')
 60     
 61     assert @prefix_5.contains_ip?( '10.72.75.15' )
 62     assert @prefix_5.contains_ip?( '10.72.74.9' )
 63     assert !@prefix_5.contains_ip?( '10.72.73.1' )
 64   end
 65 end
 66   
 67 class TestNetworkPrefixes < Test::Unit::TestCase
 68   def setup
 69     @network_1 = Network.new('test_one', '255.255.0.0')
 70     @prefix_1 = NetworkPrefix.new(@network_1, :prod, :sigma, '10.72.0.0')
 71     @prefix_2 = NetworkPrefix.new(@network_1, :prod, :pi,    '10.73.0.0')
 72     
 73     @prefixes = NetworkPrefixes.new
 74     @prefixes.add_prefix( @prefix_1 )
 75     @prefixes.add_prefix( @prefix_2 )
 76   end
 77 
 78   def test_prefix_for_ip
 79     assert_equal(nil, @prefixes.prefix_for_ip('0.0.0.0'))
 80     assert_equal(@prefix_1, @prefixes.prefix_for_ip('10.72.10.65'))
 81     assert_equal(@prefix_1, @prefixes.prefix_for_ip('10.72.165.14'))
 82     assert_equal(@prefix_2, @prefixes.prefix_for_ip('10.73.1.12'))
 83     assert_equal(nil, @prefixes.prefix_for_ip('1.2.3.4'))
 84   end
 85   
 86   def test_prefix_for_network
 87     assert_equal(@prefix_1, @prefixes.prefix_for_network('test_one', :prod, :sigma))
 88     assert_equal(@prefix_2, @prefixes.prefix_for_network('test_one', :prod, :pi))
 89     assert_equal(nil,      @prefixes.prefix_for_network('test_one', :mgmt, :sigma))
 90     assert_equal(nil,      @prefixes.prefix_for_network('test_one', :mgmt, :pi))
 91     assert_equal(nil,      @prefixes.prefix_for_network('test_one', :prod, :bogus))
 92     assert_equal(nil,      @prefixes.prefix_for_network('bogus',    :prod, :sigma))
 93   end      
 94 
 95   def test_add_prefix
 96     prefixes = NetworkPrefixes.new
 97     prefixes.add_prefix( @prefix_1 )
 98     assert_nil(prefixes.prefix_for_network('test_one', :prod, :pi))
 99     prefixes.add_prefix( @prefix_2 )
100     assert_equal(@prefix_2, prefixes.prefix_for_network('test_one', :prod, :pi))
101   end
102 
103 end

Valid XHTML 1.0!Valid CSS!