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_dblib.rb 56 56
87.5% 
86.4% 
 1 require 'dblib'
 2 require 'test/unit'
 3 
 4 class MockDB
 5 
 6   def exec(query, &block)
 7     case query.split(' ')[3]
 8     when 'zero'
 9       num = 0
10     when 'one'
11       num = 1
12     else
13       num = 2
14     end
15     
16     yield [num]
17 
18   end
19 
20 end
21 
22 class TestMockDb
23   def test_exec
24     # let's just be sure about this
25     db_connection = MockDb.new
26     assert_equal([0],db_connection.exec('foo bar baz zero'))
27     assert_equal([1],db_connection.exec('foo bar baz one'))
28     assert_equal([2],db_connection.exec('foo bar baz seven'))
29   end
30 end	
31 
32 
33 class TestDbLib <Test::Unit::TestCase
34   def test_quote
35     assert_equal("'don''t'", quote("don't"))
36   end
37 
38   def test_quote_all
39     assert_equal(["'don''t'"], quote_all(["don't"]))
40     assert_equal(["'don''t'", "'don''t'", "'don''t'"],
41                  quote_all(["don't", "don't", "don't"]))
42     assert_equal(["'don''t'"], quote_all("don't"))
43   end
44 
45   def test_record_exists?
46     db_connection = MockDB.new
47     assert ! record_exists?(db_connection, 'zero', {"foo" => "foo"})
48     assert record_exists?(db_connection, 'one', {"foo" => "foo"})
49     assert record_exists?(db_connection, 'two', {"foo" => "foo"})
50     assert record_exists?(db_connection, 'two', 
51                           {"foo" => "foo",
52                           "bar" => "bar"})
53     assert record_exists?(db_connection, 'two', {"foo" => nil})
54   end
55   
56 end

Valid XHTML 1.0!Valid CSS!