/ internal / session / title_test.go
title_test.go
 1  package session
 2  
 3  import "testing"
 4  
 5  func TestTitle(t *testing.T) {
 6  	tests := []struct {
 7  		input string
 8  		want  string
 9  	}{
10  		{"hello world", "hello world"},
11  		{"", "New session"},
12  		{"   ", "New session"},
13  		{"line1\nline2", "line1"},
14  		{"a]very long input that exceeds fifty characters and should be truncated at word boundary", "a]very long input that exceeds fifty characters..."},
15  		{"short\r\nwith crlf", "short"},
16  		// CJK: 3 bytes per rune, must not truncate mid-rune
17  		{"这是一个很长的中文标题,需要被截断到五十个字符以内,否则会显示不全的问题需要修复", "这是一个很长的中文标题,需要被截断到五十个字符以内,否则会显示不全的问题需要修复"},
18  		// Emoji: 4 bytes per rune, must not corrupt (52 runes → truncate to 50)
19  		{"你截图看看我现在这个窗口,是不是🤔🤔都有这种表情符号,测试一下是否正常显示出来了呢朋友们大家好好好好好", "你截图看看我现在这个窗口,是不是🤔🤔都有这种表情符号,测试一下是否正常显示出来了呢朋友们大家好好好好..."},
20  	}
21  	for _, tt := range tests {
22  		got := Title(tt.input)
23  		if got != tt.want {
24  			t.Errorf("Title(%q) = %q, want %q", tt.input, got, tt.want)
25  		}
26  	}
27  }
28  
29  func TestAgentTitle(t *testing.T) {
30  	if got := AgentTitle("ops-bot"); got != "ops-bot conversation" {
31  		t.Errorf("AgentTitle(ops-bot) = %q", got)
32  	}
33  }