private static bool SlicesAreEqual(Solution.Slice a, Solution.Slice b) { return(a.MinIndex == b.MinIndex && a.MaxIndex == b.MaxIndex && a.Sum == b.Sum && a.SliceLength == b.SliceLength && a.MaxValueInSlice == b.MaxValueInSlice); }
public void GetNextSlice_ExampleFirstSlice() { var A = new[] { 3, 2, -6, 3, 1 }; var nextSliceStart = 0; var expected = new Solution.Slice() { MinIndex = 0, MaxIndex = 1, Sum = 5, SliceLength = 2, MaxValueInSlice = 3 }; var actual = Solution.GetNextSlice(A, nextSliceStart); Assert.IsTrue(SlicesAreEqual(expected, actual)); }
public void GetNextSlice_DiminishedThenExceeded_JustOneSlice() { var A = new[] { 3, 2, -4, 3, 3 }; var nextSliceStart = 0; var expected = new Solution.Slice() { MinIndex = 0, MaxIndex = 4, Sum = 7, SliceLength = 5, MaxValueInSlice = 3 }; var actual = Solution.GetNextSlice(A, nextSliceStart); Assert.IsTrue(SlicesAreEqual(expected, actual)); }
public void GetNextSlice_DiminishButNotToZeroLastSlice() { var A = new[] { 3, 2, -4, 1, 1 }; var nextSliceStart = 3; var expected = new Solution.Slice() { MinIndex = 3, MaxIndex = 4, Sum = 2, SliceLength = 2, MaxValueInSlice = 1 }; var actual = Solution.GetNextSlice(A, nextSliceStart); Assert.IsTrue(SlicesAreEqual(expected, actual)); }