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_psvparse.rb 124 124
100.0% 
100.0% 
  1 require 'psvparse'
  2 require 'test/unit'
  3 
  4 class TestPSVParse < Test::Unit::TestCase
  5   def setup
  6     @web_ips = ["10.72.11.31",  "10.72.11.32", "10.72.12.31",
  7       "10.72.13.80", "10.72.14.31", "10.72.14.32", "10.72.18.31"]
  8     @parser = PSVParse.new('test/sigma_nodes.psv')
  9   end
 10 
 11   def test_search_ips
 12     assert_equal(@web_ips, @parser.search({:search_term => 'web',
 13                                           :search_field => :role,
 14 					  :result_field => :base_ip}))
 15     assert_equal(nil, @parser.search({:search_term => '',
 16                                       :search_field => :role,
 17 				      :result_field => :base_ip}))
 18   end
 19 
 20   def test_search_ips_by_group_code
 21     assert_equal(@web_ips, @parser.search({:search_term => 'web',
 22                                            :search_field => :role,
 23 					   :result_field => :base_ip}))
 24     assert_equal(['10.72.11.38'],
 25                  @parser.search({:search_term => 'upload',
 26                                   :search_field => :role,
 27 				  :result_field => :base_ip}))
 28   end
 29 
 30   def test_search_ips_by_node
 31     assert_equal(["10.72.68.59", "10.72.69.59"],
 32                  @parser.search({:search_term => 'st-wwsdb-068-059',
 33                                   :search_field => :node,
 34 			          :result_field => :base_ip}))
 35   end
 36 
 37   def test_search_ips_by_node_using_regex
 38     assert_equal(["10.72.11.31", "10.72.11.31", "10.72.11.32", "10.72.11.32"],
 39                  @parser.search({:search_term => /inws/,
 40                                   :search_field => :node,
 41 					  :result_field => :base_ip}))
 42   end
 43 
 44   def test_search_ips_bad_field
 45     assert_raise(ArgumentError) {
 46       @parser.search({:search_term => 'foo',
 47                        :search_field => :no_such_field,
 48                        :result_field => :base_ip}) }
 49   end
 50 
 51   def test_search_macs
 52     web_macs = ["00:0F:20:7A:F7:98",  "00:11:85:D4:F8:A5",
 53       "00:12:3F:20:8F:E8",  "None",  "00:0E:7F:B5:DC:C0",
 54       "00:0E:7F:30:16:B8",  "00:14:22:09:9C:0D"]
 55     assert_equal(web_macs, @parser.search({:search_term => 'web',
 56                                             :search_field => :role,
 57                                             :result_field => :mac}))
 58     assert_equal(nil, @parser.search({:search_term => '',
 59                                        :search_field => :role,
 60                                        :result_field => :mac}))
 61   end
 62 
 63   def test_search_rack
 64     assert_equal(17,@parser.search({:search_term => 'c508',
 65                                       :search_field => :rack,
 66 					  :result_field => :base_ip}).length)
 67   end
 68 
 69   def test_search_nodes
 70     web_nodes = ["inws-011-031", "inws-011-032", "dmwb-012-031",
 71       "arws-013-080", "prws-014-031", "prws-014-032", "slws-018-031"]
 72     assert_equal(web_nodes,
 73                  @parser.search({:search_term => 'web',
 74                                   :search_field => :role,
 75                                   :result_field => :node}))
 76     assert_equal(nil, @parser.search({:search_term =>'',
 77                                        :search_field => :role,
 78                                        :result_field => :node}))
 79   end
 80 
 81   def test_search_negated
 82     assert_equal(nil,@parser.search({:negated => true,
 83                                       :search_term => 'prod',
 84                                       :search_field => :net_type,
 85                                       :result_field => :base_ip}))
 86     assert_equal(815,@parser.search({:negated => true,
 87                                       :search_term =>'HP',
 88                                       :search_field => :vendor,
 89                                       :result_field => :base_ip}).length)
 90     assert_equal(815,@parser.search({:negated => true,
 91                                       :search_term => /HP/,
 92                                       :search_field => :vendor,
 93                                       :result_field => :base_ip}).length)
 94   end
 95 
 96   def test_search_return_full
 97     search_results = {:u_num=>"40", :role=>"upload", :ref=>"internal",
 98                       :pt_ip=>"10.72.0.104", :ram=>"4GB",
 99                       :mac=>"00:11:85:D4:D8:ED", :group_code=>"None",
100                       :pt_port=>"b2", nil=>nil, :disk=>"80",
101                       :base_ip=>"10.72.11.38", :subnet_mask=>"255.255.255.0",
102                       :net_type=>"prod", :raw_role=>"None",
103                       :is_core_attached=>"None", :server=>"M064MF6C3G",
104                       :rack=>"c504", :cycl_ip=>"None", :vendor=>"HP",
105                       :prefix_mask=>"255.255.0.0", :device=>"None",
106                       :prefix=>"10.72.0.0", :cycl_port=>"None",
107                       :grid=>"consonus", :net_part=>"sigma",
108                       :model=>"DL 140", :node=>"ingf-011-038"}
109     assert_equal(Hash,@parser.search({:search_term => 'upload',
110                                       :search_field => :role,
111                                      :result_field => :all})[0].class )
112     assert_equal(search_results,@parser.search({:search_term => 'upload',
113                                       :search_field => :role,
114                                      :result_field => :all})[0] )
115 
116     assert_equal(7,@parser.search({:search_term => 'web',
117                                       :search_field => :role,
118                                      :result_field => :all}).length)
119     assert_equal(12,@parser.search({:search_term => /apache/,
120                                       :search_field => :role,
121                                      :result_field => :all}).length)
122   end
123 
124 end

Valid XHTML 1.0!Valid CSS!