]> git.saurik.com Git - redis.git/blob - tests/unit/protocol.tcl
Configurable synchronous I/O timeout
[redis.git] / tests / unit / protocol.tcl
1 start_server {tags {"protocol"}} {
2 test "Handle an empty query" {
3 reconnect
4 r write "\r\n"
5 r flush
6 assert_equal "PONG" [r ping]
7 }
8
9 test "Negative multibulk length" {
10 reconnect
11 r write "*-10\r\n"
12 r flush
13 assert_equal PONG [r ping]
14 }
15
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
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 }
29
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 }
36
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 }
43
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 }
50
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 }
62 }