def test_removes_2_by_3_square_from_top_left(self): g = span_top_left(grid(5, 5), 2, 3) self.assertEqual(g['rows'][0], [spanning_cell(2, 3), cell(), cell()]) self.assertEqual(g['rows'][1], [cell(), cell()]) self.assertEqual( g['rows'][2], [cell(), cell(), cell(), cell(), cell()]) self.assertEqual( g['rows'][3], [cell(), cell(), cell(), cell(), cell()]) self.assertEqual( g['rows'][3], [cell(), cell(), cell(), cell(), cell()])
def test_degenerate_case_of_not_actually_spanning(self): g = span_top_left(grid(2, 2), 1, 1) self.assertEqual(g['rows'][0], [cell(), cell()]) self.assertEqual(g['rows'][1], [cell(), cell()])
def test_degenerate_case_of_1_by_1_grid(self): g = span_top_left(grid(1, 1), 222, 222) self.assertEqual(g['rows'], [[cell()]])
def test_degenerate_case_of_an_empty_grid(self): g = span_top_left(grid(0, 0), 222, 222) self.assertEqual(g['rows'], [])
def test_removing_huge_square_spans_the_whole_grid(self): g = span_top_left(grid(2, 2), 222, 222) self.assertEqual(g['rows'][0], [spanning_cell(2, 2)]) self.assertEqual(g['rows'][1], [])
def test_spanning_to_2_rows_removes_1_cell_from_2nd_row(self): g = span_top_left(grid(3, 2), 2, 1) self.assertEqual(g['rows'][0], [spanning_cell(2, 1), cell()]) self.assertEqual(g['rows'][1], [cell()]) self.assertEqual(g['rows'][2], [cell(), cell()])
def test_spanning_to_too_many_columns_results_in_1_cell_with_max_colspan( self): g = span_top_left(grid(2, 3), 1, 200) self.assertEqual(g['rows'][0], [spanning_cell(1, 3)])
def test_spanning_to_2_columns_removes_1_cell_from_top_row(self): g = span_top_left(grid(2, 3), 1, 2) self.assertEqual(g['rows'][0], [spanning_cell(1, 2), cell()]) self.assertEqual(g['rows'][1], [cell(), cell(), cell()])