forked from neo-project/neo-devpack-dotnet
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TestEngine: Compute coverage branches (neo-project#936)
* Compute coverage branches * fix ut * format * Reduce changes
- Loading branch information
1 parent
0cb982a
commit bb2d680
Showing
10 changed files
with
452 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Neo.SmartContract.Testing.Coverage | ||
{ | ||
[DebuggerDisplay("Offset={Offset}, Count={Count}, Hits={Hits}")] | ||
public class CoverageBranch | ||
{ | ||
/// <summary> | ||
/// Offset | ||
/// </summary> | ||
public int Offset { get; } | ||
|
||
/// <summary> | ||
/// Count | ||
/// </summary> | ||
public int Count { get; } | ||
|
||
/// <summary> | ||
/// The branch is out of the script | ||
/// </summary> | ||
public bool OutOfScript { get; } | ||
|
||
/// <summary> | ||
/// Hits | ||
/// </summary> | ||
public int Hits => (PositivePathHits > 0 ? 1 : 0) + (NegativePathHits > 0 ? 1 : 0); | ||
|
||
/// <summary> | ||
/// Positive path hits | ||
/// </summary> | ||
public int PositivePathHits { get; set; } | ||
|
||
/// <summary> | ||
/// Negative Path hits | ||
/// </summary> | ||
public int NegativePathHits { get; set; } | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
/// <param name="offset">Offset</param> | ||
/// <param name="outOfScript">Out of script</param> | ||
public CoverageBranch(int offset, bool outOfScript = false) | ||
{ | ||
Offset = offset; | ||
Count = 2; | ||
OutOfScript = outOfScript; | ||
} | ||
|
||
/// <summary> | ||
/// Hit branch | ||
/// </summary> | ||
/// <param name="value">Value</param> | ||
public void Hit(bool value) | ||
{ | ||
if (value) PositivePathHits++; | ||
else NegativePathHits++; | ||
} | ||
|
||
/// <summary> | ||
/// Hit branch | ||
/// </summary> | ||
/// <param name="value">Value</param> | ||
public void Hit(CoverageBranch value) | ||
{ | ||
PositivePathHits += value.PositivePathHits; | ||
NegativePathHits += value.NegativePathHits; | ||
} | ||
|
||
/// <summary> | ||
/// Clone branch | ||
/// </summary> | ||
/// <returns>CoverageBranch</returns> | ||
public CoverageBranch Clone() | ||
{ | ||
return new CoverageBranch(Offset, OutOfScript) | ||
{ | ||
NegativePathHits = NegativePathHits, | ||
PositivePathHits = PositivePathHits | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.