public void NullArrayTest() { bool catchException = false; try { AlgosFromCodility.PrefixSum(null); } catch (ArgumentNullException) { catchException = true; } if (catchException) { Assert.Pass(); } else { Assert.Fail(); } }
public void SliceNullArrayTest() { bool catchException = false; try { AlgosFromCodility.TotalOfSlice(null, 1, 5); } catch (ArgumentNullException) { catchException = true; } if (catchException) { Assert.Pass(); } else { Assert.Fail(); } }
public void NullArayExceptionTest() { bool catchException = false; try { AlgosFromCodility.MashroomPicker(null, 5, 10); } catch (ArgumentNullException) { catchException = true; } if (catchException) { Assert.Pass(); } else { Assert.Fail(); } }
public void WrongStartPositionTest() { bool catchException = false; try { AlgosFromCodility.MashroomPicker(new int[] { 2, 3, 7, 5, 1, 3, 9 }, 8, 10); } catch (ArgumentOutOfRangeException) { catchException = true; } if (catchException) { Assert.Pass(); } else { Assert.Fail(); } }
public void YBiggerThenArrayLengthTest() { bool catchException = false; try { AlgosFromCodility.TotalOfSlice(new long[3], 0, 5); } catch (ArgumentOutOfRangeException) { catchException = true; } if (catchException) { Assert.Pass(); } else { Assert.Fail(); } }
public void NegativeArrayTest() { Assert.AreEqual(new long[] { 0, -5, 5, 8 }, AlgosFromCodility.PrefixSum(new int[] { -5, 10, 3 })); }
public void EmptyArrayTest() { Assert.AreEqual(new long[1], AlgosFromCodility.PrefixSum(new int[0])); }
public void TwoElementsTest() { int[] A = new[] { 5, 8 }; Assert.AreEqual(new long[] { 0, 5, 13 }, AlgosFromCodility.PrefixSum(A)); }
public void OneElementTest() { Assert.AreEqual(new long [] { 0, 10 }, AlgosFromCodility.PrefixSum(new [] { 10 })); }
public void ExampleTest() { Assert.AreEqual(new long [] { 0, 1, 3, 6, 10, 15, 21 }, AlgosFromCodility.PrefixSum(Enumerable.Range(1, 6).ToArray())); }
public void NegativeSliceTest() { Assert.AreEqual(5, AlgosFromCodility.TotalOfSlice(new long[] { 0, -5, 5, 8 }, 0, 1)); }
public void OneElementSliceTest() { Assert.AreEqual(4, AlgosFromCodility.TotalOfSlice(new long[] { 0, 1, 3, 6, 10, 15, 21 }, 3, 3)); }
public void ExampleSliceTest() { Assert.AreEqual(12, AlgosFromCodility.TotalOfSlice(new long[] { 0, 1, 3, 6, 10, 15, 21 }, 2, 4)); }
public void TwoPlaceTest() { Assert.AreEqual(5, AlgosFromCodility.MashroomPicker(new [] { 2, 3 }, 0, 10)); }
public void TwoStepsTest() { Assert.AreEqual(13, AlgosFromCodility.MashroomPicker(A, 4, 2)); }
public void ZeroStepsTest() { Assert.AreEqual(9, AlgosFromCodility.MashroomPicker(A, 6, 0)); }
public void OneStepTest() { Assert.AreEqual(12, AlgosFromCodility.MashroomPicker(A, 6, 1)); }
public void ExampleTest() { Assert.AreEqual(25, AlgosFromCodility.MashroomPicker(A, 4, 6)); }