-
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.
Add unit tests for LeetCode #35 'Search Insert Position'.
- Loading branch information
1 parent
b50ee7e
commit b26f150
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...s/LeetCode.Challenges.UnitTests/Problems00xx/N_0035_SearchInsertPosition/SolutionTests.cs
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,27 @@ | ||
using Xunit; | ||
using LeetCode.Challenges.Problems00xx.N_0035_SearchInsertPosition; | ||
using Shouldly; | ||
|
||
namespace LeetCode.Challenges.UnitTests.Problems00xx.N_0035_SearchInsertPosition; | ||
|
||
public class SolutionTests | ||
{ | ||
[Theory] | ||
[MemberData(nameof(TestData))] | ||
public void GivenNumbersAndTarget_WhenSearchInsert_ThenResultAsExpected(int[] nums, int target, int expected) | ||
{ | ||
var result = Solution.SearchInsert(nums, target); | ||
result.ShouldBe(expected); | ||
} | ||
|
||
public static IEnumerable<object[]> TestData() | ||
{ | ||
yield return [new[] { 1, 3, 5, 6 }, 5, 2]; | ||
yield return [new[] { 1, 3, 5, 6 }, 2, 1]; | ||
yield return [new[] { 1, 3, 5, 6 }, 7, 4]; | ||
yield return [new[] { 1, 3, 5, 6 }, 0, 0]; | ||
yield return [new[] { 1 }, 0, 0]; | ||
yield return [new[] { 1 }, 1, 0]; | ||
yield return [new[] { 1, 3 }, 2, 1]; | ||
} | ||
} |