Ejemplo n.º 1
0
 def test_random(self):
     test_list = [
         random.randint(0, 20),
         random.randint(0, 20),
         random.randint(0, 20),
         random.randint(0, 20)
     ]
     expected_list = test_list.copy()
     expected_list.sort()
     actual_list = bs.bubble_sort(test_list)
     self.assertEqual(actual_list, expected_list)
Ejemplo n.º 2
0
 def test_one_item(self):
     self.assertEqual(bubble_sort([0]), [0])
Ejemplo n.º 3
0
 def test_empty_array(self):
     self.assertEqual(bubble_sort([]), [])
Ejemplo n.º 4
0
 def test_four_item(self):
     self.assertEqual(bubble_sort([3, 2, 1, 0]), [0, 1, 2, 3])
Ejemplo n.º 5
0
 def test_three_item(self):
     self.assertEqual(bubble_sort([2, 1, 0]), [0, 1, 2])
Ejemplo n.º 6
0
 def test_two_item(self):
     self.assertEqual(bubble_sort([1, 0]), [0, 1])
Ejemplo n.º 7
0
 def test_simple(self):
     test_list = [4, 3, 2, 1]
     expected_list = test_list.copy()
     expected_list.sort()
     actual_list = bs.bubble_sort(test_list)
     self.assertEqual(actual_list, expected_list)
Ejemplo n.º 8
0
 def test_negative(self):
     test_list = [-4, -3, -2, -1]
     expected_list = test_list.copy()
     expected_list.sort()
     actual_list = bs.bubble_sort(test_list)
     self.assertEqual(actual_list, expected_list)
Ejemplo n.º 9
0
 def test_presorted(self):
     test_list = [1, 2, 3, 4]
     expected_list = test_list.copy()
     expected_list.sort()
     actual_list = bs.bubble_sort(test_list)
     self.assertEqual(actual_list, expected_list)
Ejemplo n.º 10
0
 def test_empty(self):
     test_list = []
     expected_list = test_list.copy()
     expected_list.sort()
     actual_list = bs.bubble_sort(test_list)
     self.assertEqual(actual_list, expected_list)