예제 #1
0
 def test_negative_increment_negative_result(self):
     start, increment, limit = 2, -1, 4
     with self.assertRaises(ValueError):
         list(linear(start, increment, limit)())
예제 #2
0
 def test_negative_increment_positive_result(self):
     start, increment, limit = 4, -1, 4
     out = list(linear(start, increment, limit)())
     self.assertEqual([4, 3, 2, 1], out)
예제 #3
0
 def test_valid(self):
     start, increment, limit = 1, 1, 3
     out = list(linear(start, increment, limit)())
     self.assertEqual([1, 2, 3], out)
예제 #4
0
 def test_zero_limit(self):
     start, increment, limit = 1, 1, 0
     out = list(linear(start, increment, limit)())
     self.assertEqual([], out)
예제 #5
0
 def test_negative_limit(self):
     start, increment, limit = 1, 1, -1
     with self.assertRaises(ValueError):
         list(linear(start, increment, limit)())
예제 #6
0
 def test_zero_start(self):
     start, increment, limit = 0, 1, 1
     out = list(linear(start, increment, limit)())
     self.assertEqual([0], out)