Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for aligning numbers separately from strings #92

Merged
merged 5 commits into from
Dec 29, 2022

Conversation

DenverCoder1
Copy link
Owner

@DenverCoder1 DenverCoder1 commented Dec 28, 2022

def test_number_alignments():
    text = t2a(
        header=["1.1.1", "G", "Long Header", "Another Long Header"],
        body=[[100.00001, 2, 3.14, 6.28], [10.0001, 22.0, 2.718, 1.618]],
        alignments=[Alignment.LEFT, Alignment.RIGHT, Alignment.CENTER, Alignment.RIGHT],
        number_alignments=[Alignment.DECIMAL, Alignment.LEFT, Alignment.RIGHT, Alignment.DECIMAL],
    )
    expected = (
        "╔══════════════════════════════════════════════════════╗\n"
        "║ 1.1.1          G   Long Header   Another Long Header ║\n"
        "╟──────────────────────────────────────────────────────╢\n"
        "║ 100.00001   2             3.14                 6.28  ║\n"
        "║  10.0001    22.0         2.718                 1.618 ║\n"
        "╚══════════════════════════════════════════════════════╝"
    )
    assert text == expected
def test_single_number_alignments():
    text = t2a(
        header=["1.1.1", "G", "Long Header", "S"],
        body=[[100.00001, 2, 3.14, 6.28], [10.0001, 22.0, 2.718, 1.618]],
        alignments=[Alignment.LEFT, Alignment.CENTER, Alignment.CENTER, Alignment.RIGHT],
        number_alignments=Alignment.RIGHT,
    )
    expected = (
        "╔════════════════════════════════════════╗\n"
        "║ 1.1.1        G     Long Header       S ║\n"
        "╟────────────────────────────────────────╢\n"
        "║ 100.00001      2          3.14    6.28 ║\n"
        "║   10.0001   22.0         2.718   1.618 ║\n"
        "╚════════════════════════════════════════╝"
    )
    assert text == expected

@DenverCoder1 DenverCoder1 added the enhancement New feature or request label Dec 28, 2022
@DenverCoder1 DenverCoder1 merged commit 1a9d24d into main Dec 29, 2022
@DenverCoder1 DenverCoder1 deleted the feat/number-alignments branch December 29, 2022 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant