package main import ( "strings" "testing" ) func TestLiveCaptionDisplayTextFitsOverlayBuffer(t *testing.T) { input := strings.Repeat("这是一句实时字幕", 12) got := liveCaptionDisplayText(input) if got == "" { t.Fatal("caption should not be empty") } if len([]byte(got)) > liveCaptionMaxBytes { t.Fatalf("caption bytes = %d, want <= %d", len([]byte(got)), liveCaptionMaxBytes) } if !strings.HasPrefix(got, "...") { t.Fatalf("caption = %q, want leading truncation marker", got) } }