<s> """<STR_LIT>""" <EOL> import unittest <EOL> import sorting <EOL> class TestSortingMethods ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . unordered = [ <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:9> , <NUM_LIT:7> , <NUM_LIT:5> ] <EOL> self . ordered = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:9> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . unordered_with_dupes = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:6> , <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:5> ] <EOL> self . ordered_with_dupes = [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:6> , <NUM_LIT:7> ] <EOL> def test_static_sorts ( self ) : <EOL> original = self . unordered <EOL> sorting . selection_sort ( self . unordered ) <EOL> self . assertEqual ( original , self . unordered ) <EOL> sorting . insertion_sort ( self . unordered ) <EOL> self . assertEqual ( original , self . unordered ) <EOL> sorting . merge_sort ( self . unordered ) <EOL> self . assertEqual ( original , self . unordered ) <EOL> def test_selection_sort ( self ) : <EOL> test = sorting . selection_sort ( self . unordered ) <EOL> self . assertEqual ( test , self . ordered ) <EOL> test = sorting . selection_sort ( self . unordered_with_dupes ) <EOL> self . assertEqual ( test , self . ordered_with_dupes ) <EOL> def test_insertion_sort ( self ) : <EOL> test = sorting . insertion_sort ( self . unordered ) <EOL> self . assertEqual ( test , self . ordered ) <EOL> test = sorting . insertion_sort ( self . unordered_with_dupes ) <EOL> self . assertEqual ( test , self . ordered_with_dupes ) <EOL> def test_merge_sort ( self ) : <EOL> test = sorting . merge_sort ( self . unordered ) <EOL> self . assertEqual ( test , self . ordered ) <EOL> test = sorting . merge_sort ( self . unordered_with_dupes ) <EOL> self . assertEqual ( test , self . ordered_with_dupes ) <EOL> def test_merge ( self ) : <EOL> num1 = [ <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:20> ] <EOL> num2 = [ <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:9> , <NUM_LIT> ] <EOL> orig1 , orig2 = num1 , num2 <EOL> ans = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:9> , <NUM_LIT:20> , <NUM_LIT> ] <EOL> test = sorting . merge ( num1 , num2 ) <EOL> self . assertEqual ( test , ans ) <EOL> self . assertEqual ( orig1 , num1 ) <EOL> self . assertEqual ( orig2 , num2 ) <EOL> def test_quick_sort ( self ) : <EOL> test = self . unordered <EOL> test_with_dupes = self . unordered_with_dupes <EOL> sorting . quick_sort ( test , <NUM_LIT:0> , len ( test ) - <NUM_LIT:1> ) <EOL> sorting . quick_sort ( test_with_dupes , <NUM_LIT:0> , len ( test_with_dupes ) - <NUM_LIT:1> ) <EOL> self . assertEqual ( test , self . ordered ) <EOL> self . assertEqual ( test_with_dupes , self . ordered_with_dupes ) <EOL> def test_partition ( self ) : <EOL> test = self . unordered <EOL> ans = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:9> , <NUM_LIT:7> , <NUM_LIT> ] <EOL> pivot_ans = <NUM_LIT:1> <EOL> pivot = sorting . partition ( test , <NUM_LIT:0> , len ( test ) - <NUM_LIT:1> ) <EOL> self . assertEqual ( ans , test ) <EOL> self . assertEqual ( pivot , pivot_ans ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( verbosity = <NUM_LIT:2> ) </s>
