This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCoverageItem.cs
111 lines (88 loc) · 1.88 KB
/
CoverageItem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Collections;
namespace MonoCov {
public abstract class CoverageItem {
public int hit;
public int missed;
public double coveragePercent;
public bool filtered;
public CoverageItem parent;
public ArrayList children;
public CoverageItem () {
hit = 0;
missed = 0;
coveragePercent = 0.0;
}
public CoverageItem (CoverageItem parent) : this () {
if (parent != null)
parent.AddChildren (this);
}
public void AddChildren (CoverageItem item) {
if (children == null)
children = new ArrayList ();
children.Add (item);
item.parent = this;
}
public virtual bool IsLeaf {
get {
return false;
}
}
public int ChildCount {
get {
if (children == null)
return 0;
else
return children.Count;
}
}
public void setCoverage (int hit, int missed) {
this.hit = hit;
this.missed = missed;
if (hit + missed == 0)
coveragePercent = 100.0;
else
coveragePercent = (double)hit / (hit + missed);
}
public void computeCoveragePercent () {
if (hit + missed == 0)
coveragePercent = 100.0;
else
coveragePercent = (double)hit / (hit + missed);
}
public void computeCoverage () {
computeCoverage (false);
}
public void computeCoverage (bool recurse) {
if (IsLeaf)
return;
hit = 0;
missed = 0;
if (children != null) {
foreach (CoverageItem item in children) {
if (!item.filtered) {
if (recurse)
item.computeCoverage (recurse);
hit += item.hit;
missed += item.missed;
}
}
}
computeCoveragePercent ();
}
public void recomputeCoverage () {
computeCoverage ();
if (parent != null)
parent.recomputeCoverage ();
}
public void FilterItem (bool isFiltered) {
if (filtered != isFiltered) {
filtered = isFiltered;
recomputeCoverage ();
}
}
public override string ToString () {
return "" + GetType () + "(hit=" + hit + ", missed=" + missed + ")";
}
}
}