示例#1
0
 def test_color_column(self):
     should_be = [
         ['0', '0', 'A', '0', '0'],
         ['0', '0', 'A', '0', '0'],
         ['0', '0', 'A', '0', '0'],
     ]
     matrix = main.create_matrix(5, 3)
     main.color_column(matrix, 3, 1, 3, 'A')
     self.assertEqual(matrix, should_be)
示例#2
0
    def test_color_line(self):

        should_be = [
            ['0', '0', '0', '0', '0'],
            ['0', 'A', 'A', 'A', 'A'],
            ['0', '0', '0', '0', '0'],
        ]
        matrix = main.create_matrix(5, 3)
        main.color_line(matrix, 2, 5, 2, 'A')
        self.assertEqual(matrix, should_be)
示例#3
0
    def test_color_one(self):
        should_be = [
            ['0', '0', 'E', '0', '0'],
            ['0', '0', 'A', '0', '0'],
        ]
        matrix = main.create_matrix(5, 2)
        main.color_one(matrix, 3, 1, 'E')
        main.color_one(matrix, 3, 2, 'A')

        self.assertEqual(matrix, should_be)
示例#4
0
 def test_color_region_2(self):
     should_be = [
         ['0', '0', '0', '0', '0'],
         ['A', 'A', 'A', 'A', 'A'],
         ['B', 'B', 'B', 'B', 'B'],
     ]
     matrix = main.create_matrix(5, 3)
     main.color_line(matrix, 1, 5, 2, 'A')
     original_color = '0'
     main.color_region(matrix, 4, 3, 'B', original_color)
     self.assertEqual(matrix, should_be)
示例#5
0
    def test_write_file(self):
        # Removing previous file
        if os.path.isfile('teste.txt'):
            os.unlink('teste.txt')

        should_be = '0000\n0000\nBBBB\n'
        matrix = main.create_matrix(4, 3)
        main.color_line(matrix, 1, 4, 3, 'B')
        main.write_file(matrix, 'teste.txt')
        self.assertTrue(os.path.isfile('teste.txt'))
        self.assertEqual(open('teste.txt', 'r').read(), should_be)
示例#6
0
    def test_color_square(self):

        should_be = [
            ['0', '0', '0', '0', '0'],
            ['0', 'A', 'A', 'B', 'B'],
            ['0', 'A', 'A', 'B', 'B'],
        ]
        matrix = main.create_matrix(5, 3)
        main.color_square(matrix, 2, 2, 3, 3, 'A')
        main.color_square(matrix, 4, 2, 5, 3, 'B')

        self.assertEqual(matrix, should_be)
示例#7
0
    def test_create_matrix(self):
        should_be = [
            ['0', '0', '0', '0', '0'],
            ['0', '0', '0', '0', '0'],
            ['0', '0', '0', '0', '0'],
            ['0', '0', '0', '0', '0'],
            ['0', '0', '0', '0', '0'],
            ['0', '0', '0', '0', '0'],
        ]

        matrix = main.create_matrix(5, 6)
        self.assertEqual(matrix, should_be)