Пример #1
0
 def test_find(self):
     word_ladder.checkUserInput()
     word_ladder.findWords()
     word_ladder.find(word_ladder.start, word_ladder.words,
                      word_ladder.seen, word_ladder.target,
                      word_ladder.path)
     self.assertEqual(word_ladder.paths, [['lead', 'load', 'goad', 'gold']])
Пример #2
0
 def test_build0(self):
     word_ladder.checkUserInput()
     word_ladder.findWords()
     self.assertEqual(
         word_ladder.build0('lead', word_ladder.words, word_ladder.seen), [
             'bead', 'dead', 'head', 'leaf', 'leak', 'leal', 'lean', 'leap',
             'lear', 'leas', 'lend', 'leud', 'lewd', 'load', 'mead', 'read'
         ])
Пример #3
0
 def test_findWorld_len(self):
     word_ladder.checkUserInput()
     word_ladder.findWords()
     self.assertEqual(word_ladder.words.__len__(), 3862)
Пример #4
0
 def test_checkUserInput(self):
     word_ladder.fname = 'dictionary.txt'
     word_ladder.start = 'lead'
     word_ladder.target = 'gold'
     word_ladder.steps = 3
     self.assertTrue(word_ladder.checkUserInput())
Пример #5
0
 def test_isInDictionary_False(self):
     word_ladder.checkUserInput()
     self.assertTrue(word_ladder.isInDictionary('wordttt'))
Пример #6
0
 def test_checkUserInput_others_error(self):
     word_ladder.fname = ''
     word_ladder.start = ''
     word_ladder.target = ''
     word_ladder.steps = ''
     self.assertFalse(word_ladder.checkUserInput())
Пример #7
0
 def test_checkUserInput_target_not_in_file(self):
     word_ladder.fname = 'dictionary.txt'
     word_ladder.start = 'llll'
     word_ladder.target = 'gold'
     word_ladder.steps = 3
     self.assertFalse(word_ladder.checkUserInput())
Пример #8
0
 def test_checkUserInput_number_in_word(self):
     word_ladder.fname = 'dictionary.txt'
     word_ladder.start = 'are1'
     word_ladder.target = 'gold'
     word_ladder.steps = 3
     self.assertFalse(word_ladder.checkUserInput())
Пример #9
0
 def test_checkUserInput_not_found_file(self):
     word_ladder.fname = 'xxx.txt'
     word_ladder.start = 'lead'
     word_ladder.target = 'gold'
     word_ladder.steps = 3
     self.assertFalse(word_ladder.checkUserInput())
Пример #10
0
 def test_checkUserInput_Different_length(self):
     word_ladder.fname = 'dictionary.txt'
     word_ladder.start = 'hello'
     word_ladder.target = 'gold'
     word_ladder.steps = 3
     self.assertFalse(word_ladder.checkUserInput())