diff options
| author | historia <historiavg@proton.me> | 2026-08-28 04:45:29 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-28 04:45:29 -0400 |
| commit | 5ed31309b6d0db94ccd566914653d367f4577c64 (patch) | |
| tree | b909445125629181eb8aa38e4805f672bdaf9c20 /app/tests/test_runview.py | |
| parent | 0dda9a5921eafd03853d233e077138ff72d64e4d (diff) | |
| download | tts-audiobook-generator-5ed31309b6d0db94ccd566914653d367f4577c64.tar.gz | |
fix: japanese characters not truncated correctly in tui terminal output
Diffstat (limited to 'app/tests/test_runview.py')
| -rw-r--r-- | app/tests/test_runview.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/tests/test_runview.py b/app/tests/test_runview.py index 8feeee1..3f77ed0 100644 --- a/app/tests/test_runview.py +++ b/app/tests/test_runview.py @@ -62,10 +62,21 @@ class FormatTests(_FakeTui, unittest.TestCase): self.assertEqual(runview._fit("hello", 3), "he~") self.assertEqual(runview._fit("hi", 10), "hi") + def test_fit_truncates_wide_characters_by_display_columns(self): + # Japanese characters fill two terminal cells each, so fitting + # by character count would let lines overflow their pane. + self.assertEqual(runview._fit("你好", 4), "你好") + self.assertEqual(runview._fit("你好你好", 5), "你好~") + self.assertEqual(runview._fit("こんにちは", 3), "こ~") + def test_wrap_wraps_on_word_boundaries(self): self.assertEqual(runview._wrap("aaaa bbbb cccc dddd", 12), ["aaaa bbbb", "cccc dddd"]) + def test_wrap_counts_wide_characters_as_two_columns(self): + self.assertEqual(runview._wrap("日本語 テスト", 10), + ["日本語", "テスト"]) + class StateTransitionTests(_FakeTui, unittest.TestCase): def test_boot_flow_starting_to_ready(self): |
