Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions main/OpenCover.Framework/Model/SequencePoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace OpenCover.Framework.Model
/// <summary>
/// a sequence point
/// </summary>
public class SequencePoint : InstrumentationPoint, IDocumentReference, IEquatable<SequencePoint>
public class SequencePoint : InstrumentationPoint, IDocumentReference
{
/// <summary>
/// The start line of the sequence point
Expand Down Expand Up @@ -76,43 +76,5 @@ public bool IsSingleCharSequencePoint {
return (StartLine == EndLine) && (EndColumn - StartColumn) == 1;
}
}

#region IEquatable implementation

/// <summary>
/// Override GetHashCode
/// </summary>
/// <returns>int</returns>
public override int GetHashCode () {
return unchecked (StartLine << 3) ^ unchecked (EndLine << 2) ^ unchecked (StartColumn << 1) ^ (EndColumn);
}

/// <summary>
/// Override Equals
/// </summary>
/// <param name="obj">Object</param>
/// <returns>bool</returns>
public override bool Equals (object obj) {
var that = obj as SequencePoint;
return !ReferenceEquals(that, null) && (ReferenceEquals(this, that) || (this as IEquatable<SequencePoint>).Equals(that));
}

/// <summary>
/// IEquatable&lt;SequencePoint&gt;.Equals implementation
/// </summary>
/// <param name="other">SequencePoint</param>
/// <returns>bool</returns>
bool IEquatable<SequencePoint>.Equals(SequencePoint other)
{
return !ReferenceEquals(other, null)
&& FileId != 0
&& FileId == other.FileId
&& StartLine == other.StartLine
&& StartColumn == other.StartColumn
&& EndLine == other.EndLine
&& EndColumn == other.EndColumn;
}

#endregion
}
}
46 changes: 0 additions & 46 deletions main/OpenCover.Test/Framework/Model/SequencePointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,52 +90,6 @@ public void TrackedMethodCountIsLimitedToMax()
Assert.AreEqual(int.MaxValue, list.First(x => x.UniqueSequencePoint == 1).TrackedMethodRefs.First(x => x.UniqueId == 1).VisitCount);
}

[Test]
public void DoesNotEqualNull()
{
var point = new SequencePoint();

Assert.IsFalse(point.Equals(null));
}

[Test]
public void DoesEqualSelf()
{
var point = new SequencePoint();

Assert.IsTrue(point.Equals(point));
}

[Test]
public void DoesEqualSimilar()
{
var point1 = new SequencePoint {FileId = 1, StartLine = 1, StartColumn = 1, EndLine = 1, EndColumn = 1};
var point2 = new SequencePoint {FileId = 1, StartLine = 1, StartColumn = 1, EndLine = 1, EndColumn = 1};

Assert.IsTrue(point1.Equals(point2));
}

[Test]
[TestCase(0, 1, 1, 1, 1)]
[TestCase(1, 2, 1, 1, 1)]
[TestCase(1, 1, 3, 1, 1)]
[TestCase(1, 1, 1, 4, 1)]
[TestCase(1, 1, 1, 1, 5)]
public void DoesNotEqualDisimilar(int fileId, int startLine, int startColumn, int endLine, int endColumn)
{
var point1 = new SequencePoint { FileId = 1, StartLine = 1, StartColumn = 1, EndLine = 1, EndColumn = 1 };
var point2 = new SequencePoint
{
FileId = (uint)fileId,
StartLine = startLine,
StartColumn = startColumn,
EndLine = endLine,
EndColumn = endColumn
};

Assert.IsFalse(point1.Equals(point2));
}

[Test]
public void CanDetermineSingleCharSequencePoint()
{
Expand Down
67 changes: 67 additions & 0 deletions main/OpenCover.Test/Framework/Utility/SequencePointComparerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Created by SharpDevelop.
* User: ddur
* Date: 9.1.2016.
* Time: 15:11
*
*/
using System;
using NUnit.Framework;
using OpenCover.Framework.Model;
using OpenCover.Framework.Utility;

namespace OpenCover.Test.Framework.Utility
{
[TestFixture]
public class SequencePointComparerTest
{
SequencePointComparer comparer = new SequencePointComparer();

[Test]
public void DoesNotEqualNull()
{
var point = new SequencePoint();

Assert.IsFalse(comparer.Equals(point, null));
}

[Test]
public void DoesEqualSelf()
{
var point = new SequencePoint();

Assert.IsTrue(comparer.Equals(point, point));
}

[Test]
public void DoesEqualSimilar()
{
var point1 = new SequencePoint {FileId = 1, StartLine = 1, StartColumn = 1, EndLine = 1, EndColumn = 1};
var point2 = new SequencePoint {FileId = 1, StartLine = 1, StartColumn = 1, EndLine = 1, EndColumn = 1};

Assert.IsTrue(comparer.Equals(point1, point2));
}

[Test]
[TestCase(0, 1, 1, 1, 1)]
[TestCase(1, 2, 1, 1, 1)]
[TestCase(1, 1, 3, 1, 1)]
[TestCase(1, 1, 1, 4, 1)]
[TestCase(1, 1, 1, 1, 5)]
public void DoesNotEqualDisimilar(int fileId, int startLine, int startColumn, int endLine, int endColumn)
{
var point1 = new SequencePoint { FileId = 1, StartLine = 1, StartColumn = 1, EndLine = 1, EndColumn = 1 };
var point2 = new SequencePoint
{
FileId = (uint)fileId,
StartLine = startLine,
StartColumn = startColumn,
EndLine = endLine,
EndColumn = endColumn
};

Assert.IsFalse(comparer.Equals(point1, point2));
}

}
}
1 change: 1 addition & 0 deletions main/OpenCover.Test/OpenCover.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
<Compile Include="Framework\Symbols\CecilSymbolManagerTests.cs" />
<Compile Include="Framework\Utility\PerfCountersTests.cs" />
<Compile Include="Framework\Utility\CodeCoverageStringTextSourceTest.cs" />
<Compile Include="Framework\Utility\SequencePointComparerTest.cs" />
<Compile Include="Integration\SimpleBranchTests.cs" />
<Compile Include="Integration\SimpleExceptionTests.cs" />
<Compile Include="Integration\ThreadingTests.cs" />
Expand Down