def test_find_word_out_of_bounds(self): grid = puzzleObj2.grid wordName = list("OSLO") wordObj = Word(wordName) startCoordinates = [(1, 1), (1, 1), (9, 9), (9, 9)] for i in range(len(directions)): wordObj.startCoord = startCoordinates[i] expr = wordSearchObj._WordSearch__find_word_in_direction( grid, wordObj, directions[i]) self.assertFalse(expr, "{} starting at {}-{} is out of bounds.".format( wordObj.name, wordObj.startCoord, directions[i]))
def test_word_not_found_in_every_direction(self): # Test setup grid = puzzleObj2.grid wordName = list("POETRY") wordObj = Word(wordName) wordObj.startCoord = (5, 5) for i in range(len(directions)): expr = wordSearchObj._WordSearch__find_word_in_direction( grid, wordObj, directions[i]) self.assertFalse(expr, "{} not found {}.".format( wordObj.name, directions[i]))
def test_last_letter_not_found(self): grid = puzzleObj2.grid wordName = list("MOOD") wordObj = Word(wordName) startCoordinates = [(1, 1), (9, 9), (1, 1), (9, 9)] for i in range(len(directions)): wordObj.startCoord = startCoordinates[i] expr = wordSearchObj._WordSearch__find_word_in_direction( grid, wordObj, directions[i]) self.assertFalse(expr, "Last letter of {}(direction: {})" \ " was not found at the computed end coordinates.".format( wordObj.name, directions[i]))
def test_word_found_in_every_direction(self): # Test setup grid = puzzleObj1.grid words = ["NUM", "SYLLABLES", "SIMILE", "DIAMONTE"] startCoordinates = [(5, 0), (8, 8), (7, 1), (9, 7)] endCoordinates = [(7, 0), (0, 8), (7, 7), (9, 0)] for i in range(len(directions)): wordName = list(words[i]) wordObj = Word(wordName) wordObj.startCoord = startCoordinates[i] expr = wordSearchObj._WordSearch__find_word_in_direction( grid, wordObj, directions[i]) self.assertTrue(expr, "{} found in {} {}.".format( wordObj.name, wordObj.startCoord, wordObj.endCoord))
def test_term_with_two_words_found_in_puzzle(self): grid = puzzleObj1.grid words = puzzleObj1.words for i in range(len(words)): wordName = words[i] wordObj = Word(wordName) expr = wordSearchObj._WordSearch__find_word(grid, wordObj) self.assertTrue(expr, "{} is composed of two words.".format( wordObj.name))
def test_word_with_multiple_instance_found_in_puzzle(self): grid = puzzleObj1.grid words = ["TIC", "CIT"] for i in range(len(words)): wordName = words[i] wordObj = Word(wordName) expr = wordSearchObj._WordSearch__find_word(grid, wordObj) self.assertTrue(expr, "{} has multiple instances.".format( wordObj.name))
def test_word_not_found_in_puzzle(self): grid = puzzleObj1.grid words = ["DISNEY", "MOUSE", "RHYMES", "PATTERNS"] for i in range(len(words)): wordName = list(words[i]) wordObj = Word(wordName) expr = wordSearchObj._WordSearch__find_word(grid, wordObj) self.assertFalse(expr, "{} not found.".format( wordObj.name))
def test_word_found_in_puzzle(self): grid = puzzleObj1.grid words = ["BALL", "COUPLETS", "RHYME", "POETRY"] for i in range(len(words)): wordName = list(words[i]) wordObj = Word(wordName) expr = wordSearchObj._WordSearch__find_word(grid, wordObj) self.assertTrue(expr, "{} {} {}".format( wordObj.name, wordObj.startCoord, wordObj.endCoord))
def test_term_in_lower_case_found_in_puzzle(self): grid = puzzleObj3.grid words = puzzleObj3.words for i in range(len(words)): wordName = words[i] wordObj = Word(wordName) expr = wordSearchObj._WordSearch__find_word(grid,wordObj) self.assertTrue(expr, "{} cannot be found.".format( i + 1, wordObj.name))