Skip to content

Commit

Permalink
Update UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Pohlmann committed May 9, 2023
1 parent b604392 commit 6ef62e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System.Numerics;
using Microsoft.CodeAnalysis;
using SonarAnalyzer.SymbolicExecution.Constraints;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public void IsSingleValue()
{
NumberConstraint.From(42).IsSingleValue.Should().BeTrue();
NumberConstraint.From(1, 1).IsSingleValue.Should().BeTrue();
NumberConstraint.From(null, null).IsSingleValue.Should().BeFalse();
NumberConstraint.From(null, 42).IsSingleValue.Should().BeFalse();
NumberConstraint.From(42, null).IsSingleValue.Should().BeFalse();
NumberConstraint.Empty.IsSingleValue.Should().BeFalse();
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ Namespace Monitor_Loops

Private Condition As Boolean
Private Obj As New Object()
Private Other As New Object()

Public Sub Method1()
Monitor.Enter(Obj) ' Noncompliant tricky FP, as the execution should always reach number 9, but we don't track that
Monitor.Enter(Obj) ' Compliant for the wrong reason. Should be FP, as the execution should always reach number 9, but we don't track that
For i As Integer = 0 To 9
If i = 9 Then Monitor.Exit(Obj)
Next
Monitor.Enter(Other) ' FN, exploration stopped after loop
If Condition Then Monitor.Exit(Other)
End Sub

Public Sub Method2()
Expand All @@ -23,23 +26,25 @@ Namespace Monitor_Loops
End Sub

Public Sub Method3()
Monitor.Enter(Obj) ' Noncompliant
Monitor.Enter(Obj) ' FN, exploration stopped after loop
For i As Integer = 0 To 9
If i = 5 Then Exit For
If i = 9 Then Monitor.Exit(Obj)
Next
End Sub

Public Sub Method4()
Monitor.Enter(Obj) ' Noncompliant tricky FP, as the execution should always reach number 9, but we don't track that
Monitor.Enter(Obj) ' Compliant for the wrong reason. Should be FP, as the execution should always reach number 9, but we don't track that
For i As Integer = 0 To 9
If i = 10 Then Exit For
If i = 9 Then Monitor.Exit(Obj)
Next
Monitor.Enter(Other) ' FN, exploration stopped after loop
If Condition Then Monitor.Exit(Other)
End Sub

Public Sub Method5()
Monitor.Enter(Obj) ' Noncompliant
Monitor.Enter(Obj) ' FN, exploration stopped after loop
For i As Integer = 0 To 9
If i = 9 Then Continue For
If i = 9 Then Monitor.Exit(Obj)
Expand Down

0 comments on commit 6ef62e3

Please sign in to comment.