Esempio n. 1
0
 def test_push(self):
     test = WSdirections()
     local_dir = []
     test.append(1)
     assert test.Chosen == [1]
     test.append(2)
     assert test.Chosen == [1, 2]
     test.append(4)
     assert test.Chosen == [1, 2, 4]
     test.append(128)
     assert test.Chosen == [1, 2, 4, 128]
Esempio n. 2
0
 def test_push(self):
     test = WSdirections()
     local_dir = []
     test.append(1)
     assert test.Chosen == [1]
     test.append(2)
     assert test.Chosen == [1, 2]
     test.append(4)
     assert test.Chosen == [1, 2, 4]
     test.append(128)
     assert test.Chosen == [1, 2, 4, 128]
Esempio n. 3
0
 def test_set_directions(self):
     test = WSdirections()
     test.set_directions(5)
     assert test.Chosen == [1, 4]
     test.set_directions(127)
     assert test.Chosen == [1, 2, 4, 8, 16, 32, 64]
     test.set_directions(255)
     assert test.Chosen == [1, 2, 4, 8, 16, 32, 64, 128]
Esempio n. 4
0
 def test_pop(self):
     test = WSdirections()
     test.set_directions(255)
     assert len(test.Chosen) == 8
     local_dir = []
     for i in range(0, len(test.Chosen)):
         local_dir.append(test.pop())
     assert len(test.Chosen) == 0
     for i in range(0, 100):
         test.set_directions(255)
         local_dir = []
         for i in range(0, len(test.Chosen)):
             local_dir.append(test.pop())
         test.set_directions(255)
         assert test.Chosen != local_dir
Esempio n. 5
0
 def test_populate_matrix1(self):
     words = ['bitspace', 'extras']
     directions = WSdirections()
     test = WSmatrix((7, 9), directions.DiagDwnLeft, words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
     assert rejected == []
Esempio n. 6
0
 def test_init(self):
     directions = WSdirections()
     test = WSmatrix((11, 11), directions.Right | directions.Left,
                     self.words)
     assert test.maxrow == 11
     assert test.maxcol == 11
     assert test.directions == [directions.Right, directions.Left]
     assert test.wordlist == self.words
     print directions
Esempio n. 7
0
 def test_get_cmdline(self):
     directions = WSdirections()
     self.test.set_options()
     self.test.read_cmdline()
     filename, x, y, dir = self.test.get_cmdline()
     assert filename == 'test_options.py'
     assert x == 21
     assert y == 21
     assert dir == 1
Esempio n. 8
0
 def test_pop(self):
     test = WSdirections()
     test.set_directions(255)
     assert len(test.Chosen) == 8
     local_dir = []
     for i in range(0, len(test.Chosen)):
         local_dir.append(test.pop())
     assert len(test.Chosen) == 0
     for i in range(0, 100):
         test.set_directions(255)
         local_dir = []
         for i in range(0, len(test.Chosen)):
             local_dir.append(test.pop())
         test.set_directions(255)
         assert test.Chosen != local_dir
Esempio n. 9
0
 def test_set_directions(self):
     test = WSdirections()
     test.set_directions(5)
     assert test.Chosen == [1, 4]
     test.set_directions(127)
     assert test.Chosen == [1, 2, 4, 8, 16, 32, 64]
     test.set_directions(255)
     assert test.Chosen == [ 1, 2, 4, 8, 16, 32, 64, 128]
Esempio n. 10
0
 def test_populate_matrix(self):
     words = [
         'bitspaceX', 'this', 'one', 'will', 'do', 'just', 'fine',
         'thankyou'
     ]
     directions = WSdirections()
     test = WSmatrix((10, 10), directions.DiagDwnRight | directions.Right,
                     words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
     assert rejected == []
Esempio n. 11
0
 def test_canInsertWord(self):
     words = ['this', 'one', 'will', 'do']
     directions = WSdirections()
     test = WSmatrix((11, 11), directions.Right | directions.Left, words)
     for word in words:
         answer = test.canInsertWord(word, (0, 0), directions.Right,
                                     test.matrix)
         assert answer == True
     assert test.canInsertWord(
         'this is a very long word not to fit in grid', (0, 0),
         directions.Right, test.matrix) == False
Esempio n. 12
0
 def test_startGrid(self):
     directions = WSdirections()
     test = WSmatrix((10, 10), directions.Right | directions.Left,
                     self.words)
     matrix = test.startGrid(directions.Right, 10)
     assert len(matrix) == 10
     matrix = test.startGrid(directions.Down, 10)
     assert len(matrix) == 10
     matrix = test.startGrid(directions.Right, 9)
     assert len(matrix) == 20
     matrix = test.startGrid(directions.DiagDwnRight, 10)
     assert len(matrix) == 1
Esempio n. 13
0
 def test_longlist(self):
     words = [
         'bitspace', 'extras', 'officious', 'as', 'it', 'may', 'seem', 'to',
         'some', 'considering', 'the', 'significance', 'wonderous',
         'proposals', 'obstinate', 'peter', 'paul', 'mary', 'children',
         'christmas', 'trees', 'foundations', 'thrillseeking', 'frivolous'
     ]
     directions = WSdirections()
     test = WSmatrix((7, 9), directions.Right | directions.Left
                     | directions.Up | directions.Down, words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
Esempio n. 14
0
    def test_directions(self):
        test = WSmatrix()
        directions = WSdirections()
        assert test.directions == [directions.Right]

        test.set_directions(directions.Right | directions.Left)
        assert test.directions == [directions.Right, directions.Left]

        test.set_directions(directions.Right | directions.Left | directions.Up
                            | directions.Down)
        assert test.directions == [
            directions.Right, directions.Left, directions.Up, directions.Down
        ]
Esempio n. 15
0
 def test_populate(self):
     words = [
         'where', 'is', 'world', 'taking', 'us', 'spontaneously', 'this',
         'one', 'will', 'do', 'just', 'fine', 'thankyou'
     ]
     directions = WSdirections()
     test = WSmatrix((11, 11),
                     directions.Right | directions.Left,
                     words,
                     wstext=self.wstext)
     matrix, accepted, rejected = test.populate()
     #assert rejected == ['spontaneously', 'is', 'us']
     assert len(accepted) == 10
Esempio n. 16
0
 def setUpAll(self):
     words = [
         'bitspaceX', 'this', 'one', 'will', 'do', 'just', 'fine',
         'thankyou'
     ]
     directions = WSdirections()
     test = WSmatrix((5, 9), directions.DiagDwnRight, words)
     success, matrix, accepted, rejected = test.populate_matrix(
         test.matrix, words)
     self.format = WSformats()
     self.format.matrix = matrix
     self.format.accepted = accepted
     self.format.rejected = rejected
     self.format.solution = test.wordsplaced
Esempio n. 17
0
    def test_insertWord(self):
        words = [
            'this', 'one', 'will', 'do', 'nicely', 'fine', 'thankyou',
            'seriouslybroken'
        ]
        directions = WSdirections()
        test = WSmatrix((5, 9), directions.Right | directions.Left, words)
        matrix = test.matrix
        assert test.canInsertWord(words[0], (0, 0), directions.Right,
                                  matrix) == True

        test.debug = False
        assert test.canInsertWord(words[1:][0], (0, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[1:][0], (1, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[2], (2, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[3], (3, 0), directions.Right,
                                  matrix) == True
        assert test.canInsertWord(words[4], (4, 0), directions.Right,
                                  matrix) == True