gcov2x 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92bfc4199ed1258eff9943a3edf8664b24cdf887
4
- data.tar.gz: 58016013e879f3f047d5c758ba663a92456e1036
3
+ metadata.gz: ffc25780e4cd8a34e6bdd34e5bc8e5e994b97bad
4
+ data.tar.gz: cb9bf064b36beeea8d7c4049160ac6b1ac7446ac
5
5
  SHA512:
6
- metadata.gz: e89a2d615a40061560fa778392dde34152e4a0418df543d4efc978d83bd453ed1310f76e7b4ce82cc8b6c285e4f27cc221ecefa8d38685e00a1fc25fa8a7dc03
7
- data.tar.gz: 3cd24e8c4e3f4aed1bee699bd91f0b4f6b76fe3dbd8ef59bb4515e2cc6b4ad7efb51e08e44162433212ed274a0a984530e96bcd28236911cec532597e40e39c0
6
+ metadata.gz: 78ba1059c5cbdc8e892a7e1c83e65b3a6225fef14816d9f39a7607f4fc0af3f7426a94e8d6be0a9c0275bdaaa6f7fefdaadf67586a52e0d0a79705b0454cf77f
7
+ data.tar.gz: 1d42409446b10421d95fad13fdef204680e7b960313f5c6ce57c40fee67c2943f3f2241d03f461e8a676aae9bb3431c8908c5a5c5d96bb5493363995e4924dc7
data/lib/project.rb CHANGED
@@ -54,10 +54,18 @@ module GCOV
54
54
 
55
55
  @stats[:lines] = @stats[:exec_lines] + @stats[:missed_lines]
56
56
  @stats[:total_lines] = @stats[:lines] + @stats[:empty_lines]
57
- @stats[:coverage] = @stats[:exec_lines].to_f / @stats[:lines].to_f
57
+
58
+ if @stats[:lines] > 0
59
+ @stats[:coverage] = @stats[:exec_lines].to_f / @stats[:lines].to_f
60
+ @stats[:hits_per_line] = @stats[:total_exec].to_f / @stats[:lines]
61
+ else
62
+ @stats[:coverage] = 1
63
+ @stats[:hits_per_line] = 0
64
+ end
65
+
58
66
  @stats[:coverage_s] = sprintf("%0.01f%",100.0*@stats[:coverage])
59
- @stats[:hits_per_line] = @stats[:total_exec].to_f / @stats[:lines]
60
67
  @stats[:hits_per_line_s] = sprintf("%0.02f",@stats[:hits_per_line])
68
+
61
69
  end
62
70
 
63
71
  def add_dir path, hash={}
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GCOV
2
- VERSION = '0.4.3'
2
+ VERSION = '0.4.4'
3
3
  end
@@ -135,5 +135,36 @@ describe GCOV::Project do
135
135
  expect(project.stats[:hits_per_line]).to eq(67.0/5)
136
136
 
137
137
  end
138
- end
139
- end
138
+
139
+ it "should be computed based on file stats" do
140
+ project = GCOV::Project.new
141
+
142
+ project.add_files do
143
+ file = GCOV::File.new "myfile.cpp"
144
+ file.add_lines do
145
+ file << GCOV::Line.new(1,:none,"line 1")
146
+ file << GCOV::Line.new(2,:none,"line 2")
147
+ file << GCOV::Line.new(3,:none,"line 3")
148
+ file << GCOV::Line.new(4,:none,"line 4")
149
+ end
150
+
151
+ project << file
152
+
153
+ file = GCOV::File.new "myfile2.cpp"
154
+ file.add_lines do
155
+ file << GCOV::Line.new(1,:none,"line 1")
156
+ file << GCOV::Line.new(2,:none,"line 2")
157
+ end
158
+
159
+ project << file
160
+
161
+ end
162
+
163
+ expect(project.stats[:lines]).to eq(0)
164
+ expect(project.stats[:coverage]).to eq(1)
165
+ expect(project.stats[:hits_per_line]).to eq(0)
166
+
167
+ end # it
168
+ end # describe #stats
169
+
170
+ end # describe Project
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.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattias Bergbom