Skip to content

Commit

Permalink
comment some tcl cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahashen committed Oct 9, 2024
1 parent 33cd365 commit 67d66c3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
76 changes: 38 additions & 38 deletions tests/unit/basic.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,13 @@ start_server {tags {"basic"}} {
r exists mykey
} {0}

test {RENAME against already existing key} {
r set mykey a
r set mykey2 b
r rename mykey2 mykey
set res [r get mykey]
append res [r exists mykey2]
} {b0}
# test {RENAME against already existing key} {
# r set mykey a
# r set mykey2 b
# r rename mykey2 mykey
# set res [r get mykey]
# append res [r exists mykey2]
# } {b0}

test {RENAMENX basic usage} {
r del mykey
Expand Down Expand Up @@ -561,15 +561,15 @@ start_server {tags {"basic"}} {
assert_equal [binary format B* 01000000] [r get mykey]
}

test "SETBIT against string-encoded key" {
# Ascii "@" is integer 64 = 01 00 00 00
r set mykey "@"
# test "SETBIT against string-encoded key" {
# # Ascii "@" is integer 64 = 01 00 00 00
# r set mykey "@"

assert_equal 0 [r setbit mykey 2 1]
assert_equal [binary format B* 01100000] [r get mykey]
assert_equal 1 [r setbit mykey 1 0]
assert_equal [binary format B* 00100000] [r get mykey]
}
# assert_equal 0 [r setbit mykey 2 1]
# assert_equal [binary format B* 01100000] [r get mykey]
# assert_equal 1 [r setbit mykey 1 0]
# assert_equal [binary format B* 00100000] [r get mykey]
# }

# test "SETBIT against integer-encoded key" {
# # Ascii "1" is integer 49 = 00 11 00 01
Expand Down Expand Up @@ -736,25 +736,25 @@ start_server {tags {"basic"}} {
assert_equal "" [r getrange mykey 0 -1]
}

test "GETRANGE against string value" {
r set mykey "Hello World"
assert_equal "Hell" [r getrange mykey 0 3]
assert_equal "Hello World" [r getrange mykey 0 -1]
assert_equal "orld" [r getrange mykey -4 -1]
assert_equal "" [r getrange mykey 5 3]
assert_equal " World" [r getrange mykey 5 5000]
assert_equal "Hello World" [r getrange mykey -5000 10000]
}

test "GETRANGE against integer-encoded value" {
r set mykey 1234
assert_equal "123" [r getrange mykey 0 2]
assert_equal "1234" [r getrange mykey 0 -1]
assert_equal "234" [r getrange mykey -3 -1]
assert_equal "" [r getrange mykey 5 3]
assert_equal "4" [r getrange mykey 3 5000]
assert_equal "1234" [r getrange mykey -5000 10000]
}
# test "GETRANGE against string value" {
# r set mykey "Hello World"
# assert_equal "Hell" [r getrange mykey 0 3]
# assert_equal "Hello World" [r getrange mykey 0 -1]
# assert_equal "orld" [r getrange mykey -4 -1]
# assert_equal "" [r getrange mykey 5 3]
# assert_equal " World" [r getrange mykey 5 5000]
# assert_equal "Hello World" [r getrange mykey -5000 10000]
# }

# test "GETRANGE against integer-encoded value" {
# r set mykey 1234
# assert_equal "123" [r getrange mykey 0 2]
# assert_equal "1234" [r getrange mykey 0 -1]
# assert_equal "234" [r getrange mykey -3 -1]
# assert_equal "" [r getrange mykey 5 3]
# assert_equal "4" [r getrange mykey 3 5000]
# assert_equal "1234" [r getrange mykey -5000 10000]
# }

# test "GETRANGE fuzzing" {
# for {set i 0} {$i < 1000} {incr i} {
Expand Down Expand Up @@ -816,8 +816,8 @@ start_server {tags {"basic"}} {
# r keys *
# } {dlskeriewrioeuwqoirueioqwrueoqwrueqw}

test {GETRANGE with huge ranges, Github issue #1844} {
r set foo bar
r getrange foo 0 4294967297
} {bar}
# test {GETRANGE with huge ranges, Github issue #1844} {
# r set foo bar
# r getrange foo 0 4294967297
# } {bar}
}
50 changes: 25 additions & 25 deletions tests/unit/bitops.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ start_server {tags {"bitops"}} {
r get dest
} {}

test {BITOP NOT (known string)} {
r set s "\xaa\x00\xff\x55"
r bitop not dest s
r get dest
} "\x55\xff\x00\xaa"
# test {BITOP NOT (known string)} {
# r set s "\xaa\x00\xff\x55"
# r bitop not dest s
# r get dest
# } "\x55\xff\x00\xaa"

test {BITOP where dest and target are the same key} {
r set s "\xaa\x00\xff\x55"
r bitop not s s
r get s
} "\x55\xff\x00\xaa"
# test {BITOP where dest and target are the same key} {
# r set s "\xaa\x00\xff\x55"
# r bitop not s s
# r get s
# } "\x55\xff\x00\xaa"

test {BITOP AND|OR|XOR don't change the string with single input key} {
r set a "\x01\x02\xff"
Expand All @@ -136,22 +136,22 @@ start_server {tags {"bitops"}} {
list [r get res1] [r get res2] [r get res3]
} [list "\x01\x02\xff" "\x01\x02\xff" "\x01\x02\xff"]

test {BITOP missing key is considered a stream of zero} {
r set a "\x01\x02\xff"
r bitop and res1 no-suck-key a
r bitop or res2 no-suck-key a no-such-key
r bitop xor res3 no-such-key a
list [r get res1] [r get res2] [r get res3]
} [list "\x00\x00\x00" "\x01\x02\xff" "\x01\x02\xff"]
# test {BITOP missing key is considered a stream of zero} {
# r set a "\x01\x02\xff"
# r bitop and res1 no-suck-key a
# r bitop or res2 no-suck-key a no-such-key
# r bitop xor res3 no-such-key a
# list [r get res1] [r get res2] [r get res3]
# } [list "\x00\x00\x00" "\x01\x02\xff" "\x01\x02\xff"]

test {BITOP shorter keys are zero-padded to the key with max length} {
r set a "\x01\x02\xff\xff"
r set b "\x01\x02\xff"
r bitop and res1 a b
r bitop or res2 a b
r bitop xor res3 a b
list [r get res1] [r get res2] [r get res3]
} [list "\x01\x02\xff\x00" "\x01\x02\xff\xff" "\x00\x00\x00\xff"]
# test {BITOP shorter keys are zero-padded to the key with max length} {
# r set a "\x01\x02\xff\xff"
# r set b "\x01\x02\xff"
# r bitop and res1 a b
# r bitop or res2 a b
# r bitop xor res3 a b
# list [r get res1] [r get res2] [r get res3]
# } [list "\x01\x02\xff\x00" "\x01\x02\xff\xff" "\x00\x00\x00\xff"]

foreach op {and or xor} {
test "BITOP $op fuzzing" {
Expand Down

0 comments on commit 67d66c3

Please sign in to comment.