TestScoredSection_Sorting 测试评分排序
(t *testing.T)
| 199 | |
| 200 | // TestScoredSection_Sorting 测试评分排序 |
| 201 | func TestScoredSection_Sorting(t *testing.T) { |
| 202 | compressor := &EnhancedPromptCompressor{ |
| 203 | language: "zh", |
| 204 | } |
| 205 | |
| 206 | sections := []string{ |
| 207 | "Regular content", |
| 208 | "## IMPORTANT Security\nCritical section", |
| 209 | "## Tools Manual\nTools description", |
| 210 | "Some other text", |
| 211 | } |
| 212 | |
| 213 | scored := compressor.scoreSections(sections, []string{"Tools Manual"}) |
| 214 | |
| 215 | // 验证排序(高分在前) |
| 216 | for i := 0; i < len(scored)-1; i++ { |
| 217 | if scored[i].Score < scored[i+1].Score { |
| 218 | t.Errorf("Sections not sorted by score: %f < %f", |
| 219 | scored[i].Score, scored[i+1].Score) |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // generateLongTestPrompt 生成测试用的长 prompt |
| 225 | func generateLongTestPrompt() string { |
nothing calls this directly
no test coverage detected