forked from mirror/ledisdb
modify unit test
This commit is contained in:
parent
826961e0fc
commit
48e99a1693
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue