From 87fdc9125e6dda85e6c91e061bf5f31a7902869e Mon Sep 17 00:00:00 2001 From: wenyekui Date: Wed, 13 Aug 2014 10:26:35 +0800 Subject: [PATCH] add unit test --- ledis/t_zset.go | 3 +++ ledis/t_zset_test.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ledis/t_zset.go b/ledis/t_zset.go index e0e8e2a..5d6bfb3 100644 --- a/ledis/t_zset.go +++ b/ledis/t_zset.go @@ -995,6 +995,9 @@ func (db *DB) ZInterStore(destKey []byte, srcKeys [][]byte, weights []int64, agg } } + if _, err := db.zIncrSize(t, destKey, num); err != nil { + return 0, err + } //todo add binlog if err := t.Commit(); err != nil { return 0, err diff --git a/ledis/t_zset_test.go b/ledis/t_zset_test.go index d36572a..fc4f41f 100644 --- a/ledis/t_zset_test.go +++ b/ledis/t_zset_test.go @@ -314,6 +314,16 @@ func TestZUnionStore(t *testing.T) { if v != 4 { t.Fatal("invalid value ", v) } + + pairs, _ := db.ZRange(out, 0, -1) + n, err = db.ZCount(out, 0, 0XFFFE) + + if err != nil { + t.Fatal(err.Error()) + } + if n != 3 { + t.Fatal("invalid value ", v) + } } func TestZInterStore(t *testing.T) { @@ -365,4 +375,12 @@ func TestZInterStore(t *testing.T) { t.Fatal("invalid value ", v) } + n, err = db.ZCount(out, 0, 0XFFFF) + if err != nil { + t.Fatal(err.Error()) + } + if n != 1 { + t.Fatal("invalid value ", n) + } + }