MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / TestTruncateWithEllipsis

Class TestTruncateWithEllipsis

tests/test_terminal_utils.py:66–111  ·  view source on GitHub ↗

Tests for truncate_with_ellipsis function.

Source from the content-addressed store, hash-verified

64
65
66class TestTruncateWithEllipsis:
67 """Tests for truncate_with_ellipsis function."""
68
69 def test_no_truncation_needed(self):
70 """Test when text fits within width."""
71 assert truncate_with_ellipsis("Hello", 10) == "Hello"
72 assert truncate_with_ellipsis("Test", 5) == "Test"
73
74 def test_exact_fit(self):
75 """Test when text exactly fits."""
76 assert truncate_with_ellipsis("Hello", 5) == "Hello"
77
78 def test_ascii_truncation(self):
79 """Test truncation of ASCII text."""
80 assert truncate_with_ellipsis("Hello World", 8) == "Hello W…"
81 assert truncate_with_ellipsis("Testing", 4) == "Tes…"
82
83 def test_chinese_truncation(self):
84 """Test truncation with Chinese characters."""
85 result = truncate_with_ellipsis("你好世界", 5)
86 # Should be: 你好 (4 width) + … (1 width) = 5
87 assert calculate_display_width(result) <= 5
88 assert "…" in result
89
90 def test_emoji_truncation(self):
91 """Test truncation with emoji."""
92 result = truncate_with_ellipsis("🤖🤖🤖", 3)
93 # Should be: 🤖 (2 width) + … (1 width) = 3
94 assert calculate_display_width(result) <= 3
95
96 def test_zero_width(self):
97 """Test with zero width."""
98 assert truncate_with_ellipsis("Hello", 0) == ""
99
100 def test_width_one(self):
101 """Test with width of 1."""
102 result = truncate_with_ellipsis("Hello", 1)
103 assert len(result) <= 1
104
105 def test_ansi_codes_removed(self):
106 """Test that ANSI codes are removed during truncation."""
107 colored = "\033[31mHello World\033[0m"
108 result = truncate_with_ellipsis(colored, 8)
109 # ANSI codes should be removed
110 assert "\033[" not in result
111 assert "…" in result
112
113
114class TestPadToWidth:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected