private static void TestContainsDuplicate(int[] nums, int k, int t, bool expected) { var containsDuplicate = new ContainsDuplicateIII(); var actual = containsDuplicate.ContainsNearbyAlmostDuplicate(nums, k, t); Assert.AreEqual(expected, actual); }
public void ShouldReturnFalseWhenTIsLessThan0() { var sol = new ContainsDuplicateIII(); Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 2 }, 1, -1)); Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 1 }, 1, -1)); }
public void Test1Bucket() { var sol = new ContainsDuplicateIII(); Assert.AreEqual(false, sol.ContainsNearbyAlmostDuplicateBucket(new[] { 1, 5, 9, 1, 5, 9 }, 2, 3)); Assert.AreEqual(true, sol.ContainsNearbyAlmostDuplicateBucket(new[] { 7, 1, 3 }, 2, 3)); Assert.AreEqual(true, sol.ContainsNearbyAlmostDuplicateBucket(new[] { 1, 0, 1, 1 }, 1, 2)); }
public void ContainsNearbyAlmostDuplicateTest() { int[] nums = { 1, 2, 3, 1 }; int k = 3; int t = 0; bool expected = true; bool result = new ContainsDuplicateIII().ContainsNearbyAlmostDuplicate(nums, k, t); Assert.AreEqual(expected, result); }
public void ContainsNearbyAlmostDuplicateTest2() { int[] nums = { 1, 5, 9, 1, 5, 9 }; int k = 2; int t = 3; bool expected = false; bool result = new ContainsDuplicateIII().ContainsNearbyAlmostDuplicate(nums, k, t); Assert.AreEqual(expected, result); }
public void ContainsNearbyAlmostDuplicateTests() { ContainsDuplicateIII obj = new ContainsDuplicateIII(); // TODO:solution }
public void ShouldReturnFalseWhenNullNums() { var sol = new ContainsDuplicateIII(); Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(null, 1, 1)); }
public void Example5ShouldNotOverflow() { var sol = new ContainsDuplicateIII(); Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { -1, 2147483647 }, 1, 2147483647)); }
public void Example4ShouldReturnTrue() { var sol = new ContainsDuplicateIII(); Assert.IsTrue(sol.ContainsNearbyAlmostDuplicate(new int[] { 3, 6, 0, 4 }, 2, 2)); }
public void Example3ShouldReturnFalse() { var sol = new ContainsDuplicateIII(); Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 5, 9, 1, 5, 9 }, 2, 3)); }
public void Example1ShouldReturnTrue() { var sol = new ContainsDuplicateIII(); Assert.IsTrue(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 2, 3, 1 }, 3, 0)); }
private void ContainsDuplicateIIIUnitTestCase(int[] nums, int k, int t, bool expect) { var actual = ContainsDuplicateIII.ContainsDuplicate(nums, k, t); Assert.AreEqual(expect, actual); }