list [r msetnx x1 xxx y2 yyy] [r get x1] [r get y2]
} {1 xxx yyy}
- test {STRLEN against non existing key} {
- r strlen notakey
- } {0}
+ test "STRLEN against non-existing key" {
+ assert_equal 0 [r strlen notakey]
+ }
- test {STRLEN against integer} {
+ test "STRLEN against integer-encoded value" {
r set myinteger -555
- r strlen myinteger
- } {4}
+ assert_equal 4 [r strlen myinteger]
+ }
- test {STRLEN against plain string} {
+ test "STRLEN against plain string" {
r set mystring "foozzz0123456789 baz"
- r strlen mystring
+ assert_equal 20 [r strlen mystring]
}
test "SETBIT against non-existing key" {
r del mykey
assert_equal 4 [r setrange mykey 1 foo]
assert_equal "\000foo" [r get mykey]
-
- r del mykey
- assert_equal 3 [r setrange mykey -1 foo]
- assert_equal "foo" [r get mykey]
-
- r del mykey
- assert_equal 3 [r setrange mykey -100 foo]
- assert_equal "foo" [r get mykey]
}
test "SETRANGE against string-encoded key" {
assert_equal 3 [r setrange mykey 1 b]
assert_equal "fbo" [r get mykey]
- r set mykey "foo"
- assert_equal 6 [r setrange mykey -1 bar]
- assert_equal "foobar" [r get mykey]
-
- r set mykey "foo"
- assert_equal 5 [r setrange mykey -2 bar]
- assert_equal "fobar" [r get mykey]
-
- r set mykey "foo"
- assert_equal 3 [r setrange mykey -20 bar]
- assert_equal "bar" [r get mykey]
-
r set mykey "foo"
assert_equal 7 [r setrange mykey 4 bar]
assert_equal "foo\000bar" [r get mykey]
assert_encoding raw mykey
assert_equal 1334 [r get mykey]
- r set mykey 1234
- assert_encoding int mykey
- assert_equal 5 [r setrange mykey -1 5]
- assert_encoding raw mykey
- assert_equal 12345 [r get mykey]
-
- r set mykey 1234
- assert_encoding int mykey
- assert_equal 4 [r setrange mykey -2 5]
- assert_encoding raw mykey
- assert_equal 1235 [r get mykey]
-
r set mykey 1234
assert_encoding int mykey
assert_equal 6 [r setrange mykey 5 2]
test "SETRANGE with out of range offset" {
r del mykey
assert_error "*maximum allowed size*" {r setrange mykey [expr 512*1024*1024-4] world}
+
r set mykey "hello"
+ assert_error "*out of range*" {r setrange mykey -1 world}
assert_error "*maximum allowed size*" {r setrange mykey [expr 512*1024*1024-4] world}
}