Exemple #1
0
 def test_break_up_size_4(self):
     square = Square.from_string('####/####/..../....')
     assert square.break_up() == [
         Square.from_string('##/##'),
         Square.from_string('##/##'),
         Square.from_string('../..'),
         Square.from_string('../..')
     ]
Exemple #2
0
 def test_rotations(self):
     square = Square.from_string('###/###/...')
     assert square._rotations() == {
         square,
         Square.from_string('.##/.##/.##'),
         Square.from_string('.../###/###'),
         Square.from_string('##./##./##.')
     }
Exemple #3
0
 def test_rotations_and_flips(self):
     square = Square.from_string('#../#../...')
     assert square.rotations_and_flips() == {
         square,
         Square.from_string('..#/..#/...'),
         Square.from_string('.##/.../...'),
         Square.from_string('##./.../...'),
         Square.from_string('.../..#/..#'),
         Square.from_string('.../#../#..'),
         Square.from_string('.../.../##.'),
         Square.from_string('.../.../.##')
     }
Exemple #4
0
 def test_missing_square(self):
     book = EnhancementBook.from_strings(input_rows(21))
     assert Square.from_string('###/###/###') in book
Exemple #5
0
 def test_translate_rotated(self):
     book = EnhancementBook.from_strings(
         ['../.. => ###/.##/#..', '#./.. => #.#/..#/#..'])
     assert book[Square.from_string('../.#')] == Square.from_string(
         '#.#/..#/#..')
Exemple #6
0
 def test_count_pixels_on(self):
     square = Square.from_string('##/#.')
     assert square.count_pixels_on() == 3
Exemple #7
0
 def test_enhance_rotated(self):
     square = Square.from_string('##/..')
     book = {Square.from_string('#./#.'): Square.from_string('###/.../###')}
     assert square._enhance(book) == Square.from_string('###/.../###')
Exemple #8
0
 def test_flip(self):
     square = Square.from_string('#../#../...')
     assert square._flip() == Square.from_string('..#/..#/...')
Exemple #9
0
 def test_rotate(self):
     square = Square.from_string('###/###/...')
     assert square._rotate() == Square.from_string('.##/.##/.##')
     assert square._rotate()._rotate() == Square.from_string('.../###/###')
Exemple #10
0
 def test_combine(self):
     assert Square.from_string('.###/####/#.../....') == \
            Square.combine([Square.from_string('.#/##'),
                            Square.from_string('##/##'),
                            Square.from_string('#./..'),
                            Square.from_string('../..')])