示例#1
0
 def test_linearmaxarray_knowswhentoend(self):
     arr = [-4, 1, 1, 1, 3, -2, -9]
     actual = dac.linear_maxsubarray(arr)
     expected = (1, 4, 6)
     self.assertEqual(expected, actual)
示例#2
0
 def test_linearmaxarray_continuesovernegatives(self):
     arr = [-4, 1, 5, -3, 4, -7]
     actual = dac.linear_maxsubarray(arr)
     expected = (1, 4, 7)
     self.assertEqual(expected, actual)
示例#3
0
 def test_linearmaxarray_skipnegatives(self):
     arr = [-4, 1, 1, 2, -4]
     actual = dac.linear_maxsubarray(arr)
     expected = (1, 3, 4)
     self.assertEqual(expected, actual)
示例#4
0
 def test_linearmaxarray_straightforward(self):
     arr = [1, 2, 3, -100, -100]
     actual = dac.linear_maxsubarray(arr)
     expected = (0, 2, 6)
     self.assertEqual(expected, actual)
示例#5
0
 def test_linearmaxarray_allnegative(self):
     actual = dac.linear_maxsubarray([-3, -1, -3])
     expected = (1, 1, -1)
     self.assertEqual(expected, actual)
示例#6
0
 def test_linearmaxarray_allPositive(self):
     actual = dac.linear_maxsubarray([1, 1, 1])
     expected = (0, 2, 3)
     self.assertEqual(expected, actual)
示例#7
0
 def test_linearmaxarray_singleElement(self):
     actual = dac.linear_maxsubarray([3])
     expected = (0, 0, 3)
     self.assertEqual(expected, actual)