MCPcopy Create free account
hub / github.com/astercloud/aster / TestSectionScoring

Function TestSectionScoring

pkg/compression/service_test.go:254–286  ·  view source on GitHub ↗

TestSectionScoring 测试段落评分

(t *testing.T)

Source from the content-addressed store, hash-verified

252
253// TestSectionScoring 测试段落评分
254func TestSectionScoring(t *testing.T) {
255 svc := NewDefaultCompressionService(nil, 100)
256
257 sections := []string{
258 "## Tools Manual\nThis section describes available tools.",
259 "## Regular Section\nSome regular content here.",
260 "## Security Guidelines\nIMPORTANT: Never expose credentials.",
261 "Some text without header",
262 }
263
264 scored := svc.scoreSections(sections, []string{"Tools Manual"})
265
266 // 验证评分数量
267 if len(scored) != len(sections) {
268 t.Errorf("Expected %d scored sections, got %d", len(sections), len(scored))
269 }
270
271 // 验证必须保留的段落
272 var toolsManualScore float64
273 for _, s := range scored {
274 if strings.Contains(s.content, "Tools Manual") {
275 toolsManualScore = s.score
276 if !s.mustKeep {
277 t.Error("Expected 'Tools Manual' section to be marked as mustKeep")
278 }
279 }
280 }
281
282 // Tools Manual 应该有最高评分
283 if toolsManualScore < 1.0 {
284 t.Errorf("Expected 'Tools Manual' score = 1.0, got %f", toolsManualScore)
285 }
286}
287
288// TestExtractSectionTitle 测试提取段落标题
289func TestExtractSectionTitle(t *testing.T) {

Callers

nothing calls this directly

Calls 3

scoreSectionsMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected