Пример #1
0
    def test_fill_canvas_from_other_point(self):
        bf = lambda c: bucket(0, 0, '.', W, H, c)
        drawing = self.base_drawing(bf)

        self.assertEqual(
            pretty_render(W, H, drawing),
            textwrap.dedent("""
        +--------------------+
        |...............xxxxx|
        |xxxxxx.........x   x|
        |     x.........xxxxx|
        |     x..............|
        +--------------------+
        """))

        def test_fill_just_the_squares(self):
            bf = lambda c: bucket(0, 2, '*', W, H, c)
            br = lambda c: bucket(17, 1, '@', W, H, c)
            drawing = self.base_drawing(bf, br)

            self.assertEqual(
                pretty_render(W, H, drawing),
                textwrap.dedent("""
            +--------------------+
            |               xxxxx|
            |xxxxxx         x@@@x|
            |*****x         xxxxx|
            |*****x              |
            +--------------------+
            """))
Пример #2
0
 def test_draw_rect(self):
     drawing = rect(15, 0, 19, 2, W, H, BASE_CANVAS)
     self.assertEqual(
         pretty_render(W, H, drawing),
         textwrap.dedent("""
     +--------------------+
     |               xxxxx|
     |               x   x|
     |               xxxxx|
     |                    |
     +--------------------+
     """))
Пример #3
0
 def test_vertical_line(self):
     drawing = line(5, 2, 5, 3, W, H, BASE_CANVAS)
     self.assertEqual(
         pretty_render(W, H, drawing),
         textwrap.dedent("""
     +--------------------+
     |                    |
     |                    |
     |     x              |
     |     x              |
     +--------------------+
     """))
Пример #4
0
 def test_horizontal_line_backwards(self):
     drawing = line(5, 1, 0, 1, W, H, BASE_CANVAS)
     self.assertEqual(
         pretty_render(W, H, drawing),
         textwrap.dedent("""
     +--------------------+
     |                    |
     |xxxxxx              |
     |                    |
     |                    |
     +--------------------+
     """))
Пример #5
0
 def test_should_return_a_bordered_canvas(self):
     canvas = pretty_render(20, 4, " " * 80)
     self.assertEqual(
         canvas,
         textwrap.dedent("""
     +--------------------+
     |                    |
     |                    |
     |                    |
     |                    |
     +--------------------+
     """))
Пример #6
0
    def test_filling_the_canvas(self):
        bf = lambda c: bucket(9, 2, 'o', W, H, c)
        drawing = self.base_drawing(bf)

        self.assertEqual(
            pretty_render(W, H, drawing),
            textwrap.dedent("""
        +--------------------+
        |oooooooooooooooxxxxx|
        |xxxxxxooooooooox   x|
        |     xoooooooooxxxxx|
        |     xoooooooooooooo|
        +--------------------+
        """))