def test_converting_a_path_to_a_word(self):
     
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #2
0
 def test_converting_a_path_to_a_word(self):
     # Ensure that paths can be converted to words
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #3
0
 def test_converting_a_path_to_a_word(self): #convert path of positions into word of letters
     #ensure that paths can be converted to words
     #test checks path to word function returns same strings we manually construct in the test
     grid = boggle.make_grid(2, 2)       #can acces any letter in grid by its position 
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #4
0
 def test_converting_a_path_to_a_word(self):
     """
     Ensure That Paths Can Be Converted To Words
     """
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #5
0
 def converting_a_path_to_a_word(self):  #Converts a path to a word.
     """
     Ensure that paths can be converted to words.
     """
     grid = boggle.make_grid(2, 2)  #Make a grid 2x2
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
 def test_converting_a_path_to_a_word(self):
     """
     ENSURE THAT PATHS CAN BE CONVERTED TO WORDS
     """
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #7
0
 def test_coverting_a_path_to_a_word(self):
     """
     Ensure a path can be converted to a word
     """
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #8
0
 def test_path_to_word(self):
     """
     Test case to verify a path can be converted into words
     """
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #9
0
 def test_converting_a_path_to_a_word(self):
      """
      Ensure that paths can be converted to words
      """
      grid = boggle.make_grid(2, 2)
      oneLetterWord = boggle.path_to_word(grid, [(0, 0)]) #we can access any letter in the grid by its position, e.g here it´s 0, 0
      twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
      self.assertEqual(oneLetterWord, grid[(0, 0)])
      self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #10
0
    def test_converting_a_path_to_a_word(self):
        # Ensure that paths can be converted to words
        # The path to word function should return the same
        # strings that we manualy construct in the test
        grid = boggle.make_grid(2, 2)
        oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
        twoLetterWord = boggle.path_to_word(grid)

        self.assertEqual(oneLetterWord, grid[(0, 0)])
        self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #11
0
 def test_converting_a_path_to_a_word(
         self
 ):  # turn a path/string of positions into a word/list of letters
     """
     Ensure that paths can be converted to words
     """
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
 def test_converting_a_path_to_a_word(self):
     """
     Ensure that paths can be converted to words
     """
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(
         grid, [(0, 0)]
     )  # Our test checks that the path to word function returns the same strings we manually construct in the test.
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #13
0
    def test_converting_a_path_to_a_word(self):
        """
        Ensures that paths can be converted to words
        """
        #first we will create a random grid

        grid = boggle.make_grid(2, 2)
        oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
        twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
        self.assertEqual(oneLetterWord, grid[(0, 0)])
        self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
Beispiel #14
0
 def test_converting_a_path_to_a_word(self):
     '''
     Ensure that paths can be converted to words
     '''
     # Make random grid for now, we just want to turn letters into a string and make a word, regardless of whether the word exists
     grid = boggle.make_grid(2, 2)
     # We can access any letter in the grid by its coordinates, in this case it's 0,0
     # Ensures the function returns the same string as we manually select in the game
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEqual(oneLetterWord, grid[(0, 0)])
     self.assertEqual(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])
def all_grid_neighbours(grid):
	neighbours = {}
	for position in grid:
		position_neighbours = neighbours_of_position(position)
		neighbours[position] = [p for p in position_neighbours if p in grid]
	return neighbours

	grid = boggle.make.grid(2, 2)
	oneLetterWord = boggle.path_to_word(grid, [
	0, 0])
	twoLetterWord = boggle.path_to_word(grid, [(0,0), (1, 1)])
	self.asserEqual(oneLetterWord, grid[(0, 0)])
	self.assertEqual(teoLetterWord, grid[0, 0] + grid[(1, 1)])
Beispiel #16
0
    def test_converting_a_path_to_a_word(self):
        """
        Ensure that paths can be converted to words
        """
        grid = boggle.make_grid(2,2)
        oneLetterWord = boggle.path_to_word(grid, [(0,0)])
        twoLetterWord = boggle. path_to_word(grid, [(0,0), (1,1)])
        self. assertEqual(oneLetterWord, grid[(0,0)])
        self.assertEqual(twoLetterWord, grid[(0,0)] + grid[(1, 1)]
    def test_search_grid_for_words(self)
    """
    Ensure that certain patterns can be found in a path_to_word
    """
    grid = {(0, 0): 'A', (0, 1): 'B', (1, 0): 'C', (1, 1): 'D' }
    twoLetterWord = 'AB'
    threeLetterWord = 'ABC'
    notThereWord = 'EEE'
    fullwords = [twoLetterWord, threeLetterWord, notThereWord]
    stems = ['A', 'AB', 'E', 'EE']
    dictionary = fullwords, stems
    foundWords = boggle.search(grid, dictionary)
    self.assertTrue(twoLetterWord in foundWords)
    self.assertTrue(threeLetterWord in foundWords)
    self.assertTrue(notThereWord not in foundWords)
def test_load_dictionary(self):
    """
    Test that the 'get_dictionary' function returns a dictionary
    that has a length greater than 0
    """
    dictionary = boggle.get_dictionary('words.txt')
    self. assertGreater(len(dictionary), 0)
 def test_converting_a_path_to_a_word(self):
     grid = boggle.make_grid(2, 2)
     oneLetterWord = boggle.path_to_word(grid, [(0, 0)])
     twoLetterWord = boggle.path_to_word(grid, [(0, 0), (1, 1)])
     self.assertEquals(oneLetterWord, grid[(0, 0)])
     self.assertEquals(twoLetterWord, grid[(0, 0)] + grid[(1, 1)])