summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJason Roth <jroth2@gmail.com>2015-02-21 15:01:18 +0000
committerJason Roth <jroth2@gmail.com>2015-02-21 15:01:18 +0000
commitdb9461e466afeeb9b50a80b78934144922482f5b (patch)
treef2332c6eec6e19a08147d9e1974eeead368e41bc /tests
parent0aa5acc8f31a45ba4ee625227bae80e125fd8bdb (diff)
downloadredis-db9461e466afeeb9b50a80b78934144922482f5b.tar.gz
added a new hvstrlen command
the hvstrlen command returns the length of a hash field value
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/type/hash.tcl31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl
index fa52afd16..3d9be1fcc 100644
--- a/tests/unit/type/hash.tcl
+++ b/tests/unit/type/hash.tcl
@@ -390,6 +390,37 @@ start_server {tags {"hash"}} {
lappend rv [string match "ERR*not*float*" $bigerr]
} {1 1}
+ test {HVSTRLEN against the small hash} {
+ set err {}
+ foreach k [array names smallhash *] {
+ if {[string length $smallhash($k)] ne [r hvstrlen smallhash $k]} {
+ set err "[string length $smallhash($k)] != [r hvstrlen smallhash $k]"
+ break
+ }
+ }
+ set _ $err
+ } {}
+
+ test {HVSTRLEN against the big hash} {
+ set err {}
+ foreach k [array names bighash *] {
+ if {[string length $bighash($k)] ne [r hvstrlen bighash $k]} {
+ set err "[string length $bighash($k)] != [r hvstrlen bighash $k]"
+ break
+ }
+ }
+ set _ $err
+ } {}
+
+ test {HVSTRLEN against non existing key} {
+ set rv {}
+ lappend rv [r hvstrlen smallhash __123123123__]
+ lappend rv [r hvstrlen bighash __123123123__]
+ set _ $rv
+
+ } {{} {}}
+
+
test {Hash ziplist regression test for large keys} {
r hset hash kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk a
r hset hash kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk b