-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change BITCOUNT 'end' as optional like BITPOS #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a6f4296
5b067d3
8e813f3
64008bb
fb2e403
c758112
fc369bb
d5f0da6
729ec8b
c0dd4ee
843c84a
153625c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,10 @@ | |
| [ | ||
| "7.0.0", | ||
| "Added the `BYTE|BIT` option." | ||
| ], | ||
| [ | ||
| "8.0.0", | ||
| "`end` made optional; when called without argument the command reports the last BYTE." | ||
| ] | ||
| ], | ||
| "command_flags": [ | ||
|
|
@@ -54,24 +58,31 @@ | |
| "type": "integer" | ||
| }, | ||
| { | ||
| "name": "end", | ||
| "type": "integer" | ||
| }, | ||
| { | ||
| "name": "unit", | ||
| "type": "oneof", | ||
| "name": "end-unit-block", | ||
| "type": "block", | ||
| "optional": true, | ||
| "since": "7.0.0", | ||
| "arguments": [ | ||
| { | ||
| "name": "byte", | ||
| "type": "pure-token", | ||
| "token": "BYTE" | ||
| "name": "end", | ||
| "type": "integer" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If I didn't think it before, and it seems this is also maybe reasonable - allowing using just 'start' and '[BYTE | BIT]'. ex. It will be a quiet issue. Is this what you meant?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the one I am wondering..
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Just ignore my suggestion code changes and keep current json file. |
||
| }, | ||
| { | ||
| "name": "bit", | ||
| "type": "pure-token", | ||
| "token": "BIT" | ||
| "name": "unit", | ||
| "type": "oneof", | ||
| "optional": true, | ||
| "since": "7.0.0", | ||
| "arguments": [ | ||
| { | ||
| "name": "byte", | ||
| "type": "pure-token", | ||
| "token": "BYTE" | ||
| }, | ||
| { | ||
| "name": "bit", | ||
| "type": "pure-token", | ||
| "token": "BIT" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,13 +128,26 @@ start_server {tags {"bitops"}} { | |
| } | ||
| } | ||
|
|
||
| test {BITCOUNT with just start} { | ||
| set s "foobar" | ||
| r set s $s | ||
| assert_equal [r bitcount s 0] [count_bits "foobar"] | ||
| assert_equal [r bitcount s 1] [count_bits "oobar"] | ||
| assert_equal [r bitcount s 1000] 0 | ||
| assert_equal [r bitcount s -1] [count_bits "r"] | ||
| assert_equal [r bitcount s -2] [count_bits "ar"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add several special cases which include larger value of start, such as start = 10 or 50, Thanks
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add some new test cases in near days. thxs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added more testcases; 843c84a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: you said larger value as 10 or 50 for example, but the value 1000 is already used from others, so I also use 1000 :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hwware gently ping, just wondered if you didn't receive above comments alarm. |
||
| assert_equal [r bitcount s -1000] [count_bits "foobar"] | ||
| } | ||
|
|
||
| test {BITCOUNT with start, end} { | ||
| set s "foobar" | ||
| r set s $s | ||
| assert_equal [r bitcount s 0 -1] [count_bits "foobar"] | ||
| assert_equal [r bitcount s 1 -2] [count_bits "ooba"] | ||
| assert_equal [r bitcount s -2 1] [count_bits ""] | ||
| assert_equal [r bitcount s -2 1] 0 | ||
| assert_equal [r bitcount s -1000 0] [count_bits "f"] | ||
| assert_equal [r bitcount s 0 1000] [count_bits "foobar"] | ||
| assert_equal [r bitcount s -1000 1000] [count_bits "foobar"] | ||
|
|
||
| assert_equal [r bitcount s 0 -1 bit] [count_bits $s] | ||
| assert_equal [r bitcount s 10 14 bit] [count_bits_start_end $s 10 14] | ||
|
|
@@ -144,18 +157,18 @@ start_server {tags {"bitops"}} { | |
| assert_equal [r bitcount s 3 -34 bit] [count_bits_start_end $s 3 14] | ||
| assert_equal [r bitcount s 3 -19 bit] [count_bits_start_end $s 3 29] | ||
| assert_equal [r bitcount s -2 1 bit] 0 | ||
| assert_equal [r bitcount s -1000 14 bit] [count_bits_start_end $s 0 14] | ||
| assert_equal [r bitcount s 0 1000 bit] [count_bits $s] | ||
| assert_equal [r bitcount s -1000 1000 bit] [count_bits $s] | ||
| } | ||
|
|
||
| test {BITCOUNT with illegal arguments} { | ||
| # Used to return 0 for non-existing key instead of errors | ||
| r del s | ||
| assert_error {ERR *syntax*} {r bitcount s 0} | ||
| assert_error {ERR *syntax*} {r bitcount s 0 1 hello} | ||
| assert_error {ERR *syntax*} {r bitcount s 0 1 hello hello2} | ||
|
|
||
| r set s 1 | ||
| assert_error {ERR *syntax*} {r bitcount s 0} | ||
| assert_error {ERR *syntax*} {r bitcount s 0 1 hello} | ||
| assert_error {ERR *syntax*} {r bitcount s 0 1 hello hello2} | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.