Ejemplo n.º 1
0
 def test_value_at_the_beginning(self):
     "The value to be searched is at the beginning of the list"
     #given
     L = [2, 3, 5, 3]
     value = 2
     expected = 0
     # when
     valueAtIndex = linearSearch.for_loop(L, value)
     # then
     self.assertEqual(valueAtIndex, expected)
Ejemplo n.º 2
0
 def test_value_at_the_beginning(self):
     "The value to be searched is at the beginning of the list"
     #given
     L = [2, 3, 5, 3]
     value = 2
     expected = 0
     # when
     valueAtIndex = linearSearch.for_loop(L, value)
     # then
     self.assertEqual(valueAtIndex, expected)
Ejemplo n.º 3
0
 def test_value_not_in_list(self):
     "The value to be searched is at the end of the list"
     #given
     L = [2, 3, 5, 3]
     value = 8
     expected = -1
     # when
     valueAtIndex = linearSearch.for_loop(L, value)
     # then
     self.assertEqual(valueAtIndex, expected)
Ejemplo n.º 4
0
 def test_value_not_in_list(self):
     "The value to be searched is at the end of the list"
     #given
     L = [2, 3, 5, 3]
     value = 8
     expected = -1
     # when
     valueAtIndex = linearSearch.for_loop(L, value)
     # then
     self.assertEqual(valueAtIndex, expected)