Exemplo n.º 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']])
Exemplo n.º 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'
         ])
Exemplo n.º 3
0
 def test_findWorld_len(self):
     word_ladder.checkUserInput()
     word_ladder.findWords()
     self.assertEqual(word_ladder.words.__len__(), 3862)
Exemplo n.º 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())
Exemplo n.º 5
0
 def test_isInDictionary_False(self):
     word_ladder.checkUserInput()
     self.assertTrue(word_ladder.isInDictionary('wordttt'))
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())