# unscrambletest.py # Lillian Lee (LJL2) and Steve Marschner (SRM2) # Mar 3 2014 # You should not need to modify this file import unscramble import cornelltest def test_sort_string_letters(): t = 'opython' cornelltest.assert_equals('hnoopty', unscramble.sort_string_letters(t)) # Make sure nothing happened to t cornelltest.assert_equals('opython', t) t = 'typhoon' cornelltest.assert_equals('hnoopty', unscramble.sort_string_letters(t)) t = 'hnoopty' cornelltest.assert_equals('hnoopty', unscramble.sort_string_letters(t)) t = 'bcD' cornelltest.assert_equals('Dbc', unscramble.sort_string_letters(t)) print "finished test of sort_string_letters" def test_unscramblefn_idea(): word = 'dead' word_rep = 'adde' first_rewrite = 'edda' # An anagram of 'dead' known to be the first one # to appear in either scowl_utf-8.txt or # small_dict.txt # Demonstrate that word and first_rewrite have the same LSR cornelltest.assert_equals(word_rep, unscramble.sort_string_letters(word)) cornelltest.assert_equals(word_rep, unscramble.sort_string_letters(first_rewrite)) # Check that the word at the matching position in the original wordlist # is indeed the first rewrite, alphabetically, of the word 'dead' cornelltest.assert_true(first_rewrite in unscramble.dictionary) cornelltest.assert_true(word_rep in unscramble.rep_dict) irep = unscramble.rep_dict.index(word_rep) cornelltest.assert_true(unscramble.dictionary[irep] == first_rewrite) print "finished test of main idea in function unscramble" if __name__ == '__main__': test_sort_string_letters() test_unscramblefn_idea() print 'All our automatic helper tests for module unscramble passed.' print 'BUT, you must run unscramble.py on the command line to see if it works!'