modify unit test

This commit is contained in:
wenyekui 2014-08-13 15:38:59 +08:00
parent 826961e0fc
commit 48e99a1693
2 changed files with 5 additions and 5 deletions

View File

@ -899,7 +899,7 @@ func (db *DB) ZUnionStore(destKey []byte, srcKeys [][]byte, weights []int64, agg
}
for _, pair := range scorePairs {
if score, ok := destMap[String(pair.Member)]; !ok {
destMap[String(pair.Member)] = pair.Score
destMap[String(pair.Member)] = pair.Score * weights[i]
} else {
destMap[String(pair.Member)] = aggregateFunc(score, pair.Score*weights[i])
}
@ -966,7 +966,7 @@ func (db *DB) ZInterStore(destKey []byte, srcKeys [][]byte, weights []int64, agg
}
for _, pair := range scorePairs {
if score, ok := destMap[String(pair.Member)]; !ok {
destMap[String(pair.Member)] = pair.Score
destMap[String(pair.Member)] = pair.Score * weights[i]
} else {
keptMembers = append(keptMembers, pair.Member)
destMap[String(pair.Member)] = aggregateFunc(score, pair.Score*weights[i])

View File

@ -338,7 +338,7 @@ func TestZInterStore(t *testing.T) {
db.ZAdd(key2, ScorePair{2, []byte("three")})
keys := [][]byte{key1, key2}
weights := []int64{1, 2}
weights := []int64{2, 3}
out := []byte("out")
n, err := db.ZInterStore(out, keys, weights, AggregateSum)
@ -352,7 +352,7 @@ func TestZInterStore(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
if v != 5 {
if v != 8 {
t.Fatal("invalid value ", v)
}
@ -370,7 +370,7 @@ func TestZInterStore(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
if v != 1 {
if v != 2 {
t.Fatal("invalid value ", v)
}