gcov2x 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57ca01f2da6206ff1936eba7046078bf6ce498f7
4
- data.tar.gz: fddbcd737085afd8fc9139886fa8592c7853c980
3
+ metadata.gz: 92bfc4199ed1258eff9943a3edf8664b24cdf887
4
+ data.tar.gz: 58016013e879f3f047d5c758ba663a92456e1036
5
5
  SHA512:
6
- metadata.gz: c1418669ecc7dabbcc5eb66ee02416a731ce6261f67af75177852227208a9f3dd95df98905114e7ac402bdfa756965a612cc9b79a0840889a23b22d932ce7abe
7
- data.tar.gz: 08a95cea4f181a4ad6ba3d5352fb6ce4a3acfcebb7d65354c2d9d1972b8c9deae3bb8de9733114556e105badea92e41fc227a504128cededb08b6dedf9f0186d
6
+ metadata.gz: e89a2d615a40061560fa778392dde34152e4a0418df543d4efc978d83bd453ed1310f76e7b4ce82cc8b6c285e4f27cc221ecefa8d38685e00a1fc25fa8a7dc03
7
+ data.tar.gz: 3cd24e8c4e3f4aed1bee699bd91f0b4f6b76fe3dbd8ef59bb4515e2cc6b4ad7efb51e08e44162433212ed274a0a984530e96bcd28236911cec532597e40e39c0
data/lib/file.rb CHANGED
@@ -57,10 +57,18 @@ module GCOV
57
57
 
58
58
  @stats[:lines] = @stats[:exec_lines] + @stats[:missed_lines]
59
59
  @stats[:total_lines] = @stats[:lines] + @stats[:empty_lines]
60
- @stats[:coverage] = @stats[:exec_lines].to_f / @stats[:lines].to_f
60
+
61
+ if @stats[:lines] > 0
62
+ @stats[:coverage] = @stats[:exec_lines].to_f / @stats[:lines].to_f
63
+ @stats[:hits_per_line] = @stats[:total_exec].to_f / @stats[:lines]
64
+ else
65
+ @stats[:coverage] = 1
66
+ @stats[:hits_per_line] = 0
67
+ end
68
+
61
69
  @stats[:coverage_s] = sprintf("%0.01f%",100.0*@stats[:coverage])
62
- @stats[:hits_per_line] = @stats[:total_exec].to_f / @stats[:lines]
63
70
  @stats[:hits_per_line_s] = sprintf("%0.02f",@stats[:hits_per_line])
71
+
64
72
  end
65
73
 
66
74
  def <<(line)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GCOV
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
@@ -41,6 +41,19 @@ describe GCOV::File do
41
41
  expect(file.stats[:coverage]).to eq(0.5)
42
42
  expect(file.stats[:hits_per_line]).to eq(27.0/4)
43
43
  end
44
+
45
+ it "handles files with 0 executable lines" do
46
+ file = GCOV::File.new "myfile.cpp"
47
+ file.add_lines do
48
+ file << GCOV::Line.new(1,:none,"line 1")
49
+ file << GCOV::Line.new(2,:none,"line 2")
50
+ file << GCOV::Line.new(3,:none,"line 3")
51
+ file << GCOV::Line.new(4,:none,"line 4")
52
+ end
53
+ expect(file.stats[:lines]).to eq(0)
54
+ expect(file.stats[:coverage]).to eq(1)
55
+ expect(file.stats[:hits_per_line]).to eq(0)
56
+ end
44
57
  end
45
58
 
46
59
  describe "#lines" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcov2x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattias Bergbom