Skip to content

Commit ce71b7f

Browse files
committed
switch floor and ceiling
1 parent 96f590d commit ce71b7f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

table2ascii/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def __pad(self, text: str, width: int, alignment: int = ALIGN_CENTER):
107107
return f" {text} " + (" " * (width - len(text) - 2))
108108
if alignment == ALIGN_CENTER:
109109
# pad with spaces, half on each side
110-
before = " " * ceil((width - len(text) - 2) / 2)
111-
after = " " * floor((width - len(text) - 2) / 2)
110+
before = " " * floor((width - len(text) - 2) / 2)
111+
after = " " * ceil((width - len(text) - 2) / 2)
112112
return before + f" {text} " + after
113113
if alignment == ALIGN_RIGHT:
114114
# pad with spaces at the beginning

tests/test_convert.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_header_body_footer():
1313
"╔═════╦═══════════════════════╗\n"
1414
"║ # ║ G H R S ║\n"
1515
"╟─────╫───────────────────────╢\n"
16-
"║ 1 ║ 30 40 35 30 ║\n"
17-
"║ 2 ║ 30 40 35 30 ║\n"
16+
"║ 1 ║ 30 40 35 30 \n"
17+
"║ 2 ║ 30 40 35 30 \n"
1818
"╟─────╫───────────────────────╢\n"
1919
"║ SUM ║ 130 140 135 130 ║\n"
2020
"╚═════╩═══════════════════════╝\n"
@@ -29,8 +29,8 @@ def test_body_footer():
2929
)
3030
expected = (
3131
"╔═════╦═══════════════════════╗\n"
32-
"║ 1 ║ 30 40 35 30 ║\n"
33-
"║ 2 ║ 30 40 35 30 ║\n"
32+
"║ 1 ║ 30 40 35 30 \n"
33+
"║ 2 ║ 30 40 35 30 \n"
3434
"╟─────╫───────────────────────╢\n"
3535
"║ SUM ║ 130 140 135 130 ║\n"
3636
"╚═════╩═══════════════════════╝\n"
@@ -45,7 +45,7 @@ def test_header_body():
4545
)
4646
expected = (
4747
"╔═══╦═══════════════════╗\n"
48-
"║ # ║ G H R S ║\n"
48+
"║ # ║ G H R S \n"
4949
"╟───╫───────────────────╢\n"
5050
"║ 1 ║ 30 40 35 30 ║\n"
5151
"║ 2 ║ 30 40 35 30 ║\n"

0 commit comments

Comments
 (0)