Exemplo n.º 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('../..')
     ]
Exemplo n.º 2
0
 def test_rotations(self):
     square = Square.from_string('###/###/...')
     assert square._rotations() == {
         square,
         Square.from_string('.##/.##/.##'),
         Square.from_string('.../###/###'),
         Square.from_string('##./##./##.')
     }
Exemplo n.º 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('.../.../.##')
     }
Exemplo n.º 4
0
 def test_missing_square(self):
     book = EnhancementBook.from_strings(input_rows(21))
     assert Square.from_string('###/###/###') in book
Exemplo n.º 5
0
 def test_translate_rotated(self):
     book = EnhancementBook.from_strings(
         ['../.. => ###/.##/#..', '#./.. => #.#/..#/#..'])
     assert book[Square.from_string('../.#')] == Square.from_string(
         '#.#/..#/#..')
Exemplo n.º 6
0
 def test_count_pixels_on(self):
     square = Square.from_string('##/#.')
     assert square.count_pixels_on() == 3
Exemplo n.º 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('###/.../###')
Exemplo n.º 8
0
 def test_flip(self):
     square = Square.from_string('#../#../...')
     assert square._flip() == Square.from_string('..#/..#/...')
Exemplo n.º 9
0
 def test_rotate(self):
     square = Square.from_string('###/###/...')
     assert square._rotate() == Square.from_string('.##/.##/.##')
     assert square._rotate()._rotate() == Square.from_string('.../###/###')
Exemplo n.º 10
0
 def test_combine(self):
     assert Square.from_string('.###/####/#.../....') == \
            Square.combine([Square.from_string('.#/##'),
                            Square.from_string('##/##'),
                            Square.from_string('#./..'),
                            Square.from_string('../..')])