forked from alicijabulota/new_data_structures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_radix_sort.py
36 lines (26 loc) · 1.22 KB
/
test_radix_sort.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import random
from radix_sort import r_sort, string_radix
def test_sort_one():
x = random.sample(range(100000), 100000)
assert r_sort(x) == range(100000)
def test_sort_two():
sr = r_sort(range(10000, -1, -1))
assert sr == range(0, 10001)
def test_sort_three():
somestring = ("of", "words", "shit", "n")
assert string_radix(somestring) == ['n', 'of', 'shit', 'words']
def test_big_strings():
bigstring = ["this is a big string", "Here is a big one too",
"honestly I'm not too sure what to put in this one"]
assert string_radix(bigstring) == ['Here is a big one too',
"honestly I'm not too sure what to put in this one",
'this is a big string']
def test_huge_input():
# open the file and name it afile
with open("/usr/share/dict/words", "r") as afile:
# loop through all the words in the file and bind them to 'word'
word = [i for i in afile]
# radix sort the words, they then need to be asserted to a sorted
# version of the same file because radix orders the capitol letters
# first where they come all mixed up
assert string_radix(word) == sorted(word)