# Path: terminaltables/width_and_alignment.py
# def max_dimensions(table_data, padding_left=0, padding_right=0, padding_top=0, padding_bottom=0):
#     """Get maximum widths of each column and maximum height of each row.
# 
#     :param iter table_data: List of list of strings (unmodified table data).
#     :param int padding_left: Number of space chars on left side of cell.
#     :param int padding_right: Number of space chars on right side of cell.
#     :param int padding_top: Number of empty lines on top side of cell.
#     :param int padding_bottom: Number of empty lines on bottom side of cell.
# 
#     :return: 4-item tuple of n-item lists. Inner column widths and row heights, outer column widths and row heights.
#     :rtype: tuple
#     """
#     inner_widths = [0] * (max(len(r) for r in table_data) if table_data else 0)
#     inner_heights = [0] * len(table_data)
# 
#     # Find max width and heights.
#     for j, row in enumerate(table_data):
#         for i, cell in enumerate(row):
#             if not hasattr(cell, 'count') or not hasattr(cell, 'splitlines'):
#                 cell = str(cell)
#             if not cell:
#                 continue
#             inner_heights[j] = max(inner_heights[j], cell.count('\n') + 1)
#             inner_widths[i] = max(inner_widths[i], *[visible_width(l) for l in cell.splitlines()])
# 
#     # Calculate with padding.
#     outer_widths = [padding_left + i + padding_right for i in inner_widths]
#     outer_heights = [padding_top + i + padding_bottom for i in inner_heights]
# 
#     return inner_widths, inner_heights, outer_widths, outer_heights


import pytest
from colorama import Fore
from colorclass import Color
from termcolor import colored
from terminaltables.width_and_alignment import max_dimensions


@pytest.mark.parametrize('table_data,expected_w,expected_h', [
    ([[]], [], [0]),
    ([['']], [0], [0]),
    ([['', '']], [0, 0], [0]),

    ([[], []], [], [0, 0]),
    ([[''], ['']], [0], [0, 0]),
    ([['', ''], ['', '']], [0, 0], [0, 0]),
])
def test_zero_length(table_data, expected_w, expected_h):
    """Test zero-length or empty tables.

    :param list table_data: Input table data to test.
    :param list expected_w: Expected widths.
    :param list expected_h: Expected heights.
    """
    actual = max_dimensions(table_data)
    assert actual == (expected_w, expected_h, expected_w, expected_h)


def test_single_line():
    """Test widths."""
    table_data = [
        ['Name', 'Color', 'Type'],
        ['Avocado', 'green', 'nut'],
        ['Tomato', 'red', 'fruit'],
        ['Lettuce', 'green', 'vegetable'],
    ]

# Path: terminaltables/width_and_alignment.py
# def max_dimensions(table_data, padding_left=0, padding_right=0, padding_top=0, padding_bottom=0):
#     """Get maximum widths of each column and maximum height of each row.
# 
#     :param iter table_data: List of list of strings (unmodified table data).
#     :param int padding_left: Number of space chars on left side of cell.
#     :param int padding_right: Number of space chars on right side of cell.
#     :param int padding_top: Number of empty lines on top side of cell.
#     :param int padding_bottom: Number of empty lines on bottom side of cell.
# 
#     :return: 4-item tuple of n-item lists. Inner column widths and row heights, outer column widths and row heights.
#     :rtype: tuple
#     """
#     inner_widths = [0] * (max(len(r) for r in table_data) if table_data else 0)
#     inner_heights = [0] * len(table_data)
# 
#     # Find max width and heights.
#     for j, row in enumerate(table_data):
#         for i, cell in enumerate(row):
#             if not hasattr(cell, 'count') or not hasattr(cell, 'splitlines'):
#                 cell = str(cell)
#             if not cell:
#                 continue
#             inner_heights[j] = max(inner_heights[j], cell.count('\n') + 1)
#             inner_widths[i] = max(inner_widths[i], *[visible_width(l) for l in cell.splitlines()])
# 
#     # Calculate with padding.
#     outer_widths = [padding_left + i + padding_right for i in inner_widths]
#     outer_heights = [padding_top + i + padding_bottom for i in inner_heights]
# 
#     return inner_widths, inner_heights, outer_widths, outer_heights


# Path: tests/test_width_and_alignment/test_max_dimensions.py
import pytest
from colorama import Fore
from colorclass import Color
from termcolor import colored
from terminaltables.width_and_alignment import max_dimensions



@pytest.mark.parametrize('table_data,expected_w,expected_h', [
    ([[]], [], [0]),
    ([['']], [0], [0]),
    ([['', '']], [0, 0], [0]),

    ([[], []], [], [0, 0]),
    ([[''], ['']], [0], [0, 0]),
    ([['', ''], ['', '']], [0, 0], [0, 0]),
])
def test_zero_length(table_data, expected_w, expected_h):
    """Test zero-length or empty tables.

    :param list table_data: Input table data to test.
    :param list expected_w: Expected widths.
    :param list expected_h: Expected heights.
    """
    actual = max_dimensions(table_data)
    assert actual == (expected_w, expected_h, expected_w, expected_h)


def test_single_line():
    """Test widths."""
    table_data = [
        ['Name', 'Color', 'Type'],
        ['Avocado', 'green', 'nut'],
        ['Tomato', 'red', 'fruit'],
        ['Lettuce', 'green', 'vegetable'],
    ]

    assert max_dimensions(table_data, 1, 1) == ([7, 5, 9], [1, 1, 1, 1], [9, 7, 11], [1, 1, 1, 1])