def test_selection_sort_with_none_iterable_raises_type_error(self):
   iterable = None
   with self.assertRaises(TypeError):
     algorithms.selection_sort(iterable)
 def test_selection_sort_with_strings(self):
   iterable = ['a', 's', 'd', 'f']
   algorithms.selection_sort(iterable)
   expected = ['a', 'd', 'f', 's']
   self.assertEqual(iterable, expected)
 def test_selection_sort_with_no_items(self):
   iterable = []
   algorithms.selection_sort(iterable)
   expected = []
   self.assertEqual(iterable, expected)
 def test_selection_sort_with_three_items_6(self):
   iterable = [3, 2, 1]
   algorithms.selection_sort(iterable)
   expected = [1, 2, 3]
   self.assertEqual(iterable, expected)
 def test_selection_sort_with_descending_items(self):
   iterable = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
   algorithms.selection_sort(iterable)
   expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
   self.assertEqual(iterable, expected)
 def test_selection_sort_with_two_items_2(self):
   iterable = [2, 1]
   algorithms.selection_sort(iterable)
   expected = [1, 2]
   self.assertEqual(iterable, expected)
def test_descending_array(descending_array):
    assert selection_sort(descending_array) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def test_empty_array(empty_array):
    assert selection_sort(empty_array) == []
def test_identical_array(identical_array):
    assert selection_sort(identical_array) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Ejemplo n.º 10
0
from algorithms import selection_sort
import random

l = list(map(lambda x: random.randint(10, 99), range(12)))

print(l)
selection_sort(l)
print(l)

words = ['y', 'n', 'hello', 'goodbye', 'please', 'thanks']
selection_sort(words)
print(words)