瀏覽代碼

添加紧密度计算单元测试(可致旧版本的错误下标出错)

root 12 年之前
父節點
當前提交
15a3af9204
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      core/indexer_test.go

+ 12 - 0
core/indexer_test.go

@@ -233,6 +233,18 @@ func TestLookupWithProximity(t *testing.T) {
 	})
 	utils.Expect(t, "[0 8 [3 12 15]] ",
 		indexedDocsToString(indexer.Lookup([]string{"t1", "t2", "t3"}, []string{}, nil)))
+
+	// doc0 = "t3 t2 t1 . . . . . t2 t3"
+	indexer.AddDocument(&types.DocumentIndex{
+		DocId: 0,
+		Keywords: []types.KeywordIndex{
+			{"t1", 0, []int{6}},
+			{"t2", 0, []int{3, 19}},
+			{"t3", 0, []int{0, 22}},
+		},
+	})
+	utils.Expect(t, "[0 10 [6 3 0]] ",
+		indexedDocsToString(indexer.Lookup([]string{"t1", "t2", "t3"}, []string{}, nil)))
 }
 
 func TestLookupWithPartialLocations(t *testing.T) {