add TTL key codec test

This commit is contained in:
siddontang 2015-03-16 09:20:13 +08:00
parent c718387d8d
commit 13cc446870
1 changed files with 28 additions and 0 deletions

View File

@ -437,3 +437,31 @@ func TestExpCompose(t *testing.T) {
return return
} }
func TestTTLCodec(t *testing.T) {
db := getTestDB()
key := []byte("key")
ek := db.expEncodeTimeKey(KVType, key, 10)
if tp, k, when, err := db.expDecodeTimeKey(ek); err != nil {
t.Fatal(err)
} else if tp != KVType {
t.Fatal(tp, KVType)
} else if string(k) != "key" {
t.Fatal(string(k))
} else if when != 10 {
t.Fatal(when)
}
ek = db.expEncodeMetaKey(KVType, key)
if tp, k, err := db.expDecodeMetaKey(ek); err != nil {
t.Fatal(err)
} else if tp != KVType {
t.Fatal(tp, KVType)
} else if string(k) != "key" {
t.Fatal(string(k))
}
}