]> git.saurik.com Git - redis.git/blame - tests/unit/protocol.tcl
Configurable synchronous I/O timeout
[redis.git] / tests / unit / protocol.tcl
CommitLineData
08f55b78 1start_server {tags {"protocol"}} {
dc11daf3
PN
2 test "Handle an empty query" {
3 reconnect
4 r write "\r\n"
5 r flush
6 assert_equal "PONG" [r ping]
7 }
98578b57 8
dc11daf3
PN
9 test "Negative multibulk length" {
10 reconnect
11 r write "*-10\r\n"
12 r flush
13 assert_equal PONG [r ping]
14 }
98578b57 15
b19c33d4
PN
16 test "Out of range multibulk length" {
17 reconnect
18 r write "*20000000\r\n"
19 r flush
20 assert_error "*invalid multibulk length*" {r read}
21 }
22
dc11daf3
PN
23 test "Wrong multibulk payload header" {
24 reconnect
25 r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\nfooz\r\n"
26 r flush
27 assert_error "*expected '$', got 'f'*" {r read}
28 }
98578b57 29
dc11daf3
PN
30 test "Negative multibulk payload length" {
31 reconnect
32 r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$-10\r\n"
33 r flush
34 assert_error "*invalid bulk length*" {r read}
35 }
98578b57 36
dc11daf3
PN
37 test "Out of range multibulk payload length" {
38 reconnect
39 r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$2000000000\r\n"
40 r flush
41 assert_error "*invalid bulk length*" {r read}
42 }
01daeece 43
dc11daf3
PN
44 test "Non-number multibulk payload length" {
45 reconnect
46 r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$blabla\r\n"
47 r flush
48 assert_error "*invalid bulk length*" {r read}
49 }
98578b57 50
dc11daf3
PN
51 test "Multi bulk request not followed by bulk arguments" {
52 reconnect
53 r write "*1\r\nfoo\r\n"
54 r flush
55 assert_error "*expected '$', got 'f'*" {r read}
56 }
57
58 test "Generic wrong number of args" {
59 reconnect
60 assert_error "*wrong*arguments*ping*" {r ping x y z}
61 }
98578b57 62}