chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package text_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"academy/cli/internal/text"
|
||||
)
|
||||
|
||||
func TestTruncate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
maxWidth int
|
||||
s string
|
||||
want string
|
||||
}{
|
||||
{"no truncate ASCII", 20, "hello", "hello"},
|
||||
{"truncate ASCII", 5, "hello world", "hell…"},
|
||||
{"no truncate CJK", 8, "中文测试", "中文测试"},
|
||||
{"truncate CJK", 5, "中文测试", "中文…"},
|
||||
{"empty", 5, "", ""},
|
||||
{"single char fits", 1, "a", "a"},
|
||||
{"truncate to width 1", 1, "abc", "…"},
|
||||
{"maxWidth zero", 0, "x", ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got := text.Truncate(tt.maxWidth, tt.s)
|
||||
if got != tt.want {
|
||||
t.Errorf("Truncate(%d, %q) = %q, want %q", tt.maxWidth, tt.s, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user