Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
e30db1a3
Commit
e30db1a3
authored
May 14, 2016
by
not-a-robot
Browse files
Auto merge of #427 - redis:pr-426, r=badboy
Pr 426 Closes #426, now with test
parents
e93c05a7
8655a6ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
e30db1a3
...
...
@@ -507,7 +507,7 @@ int redisFormatSdsCommandArgv(sds *target, int argc, const char **argv,
cmd
=
sdscatfmt
(
cmd
,
"*%i
\r\n
"
,
argc
);
for
(
j
=
0
;
j
<
argc
;
j
++
)
{
len
=
argvlen
?
argvlen
[
j
]
:
strlen
(
argv
[
j
]);
cmd
=
sdscatfmt
(
cmd
,
"$%
T
\r\n
"
,
len
);
cmd
=
sdscatfmt
(
cmd
,
"$%
u
\r\n
"
,
len
);
cmd
=
sdscatlen
(
cmd
,
argv
[
j
],
len
);
cmd
=
sdscatlen
(
cmd
,
"
\r\n
"
,
sizeof
(
"
\r\n
"
)
-
1
);
}
...
...
test.c
View file @
e30db1a3
...
...
@@ -224,6 +224,22 @@ static void test_format_commands(void) {
test_cond
(
strncmp
(
cmd
,
"*3
\r\n
$3
\r\n
SET
\r\n
$7
\r\n
foo
\0
xxx
\r\n
$3
\r\n
bar
\r\n
"
,
len
)
==
0
&&
len
==
4
+
4
+
(
3
+
2
)
+
4
+
(
7
+
2
)
+
4
+
(
3
+
2
));
free
(
cmd
);
sds
sds_cmd
;
sds_cmd
=
sdsempty
();
test
(
"Format command into sds by passing argc/argv without lengths: "
);
len
=
redisFormatSdsCommandArgv
(
&
sds_cmd
,
argc
,
argv
,
NULL
);
test_cond
(
strncmp
(
sds_cmd
,
"*3
\r\n
$3
\r\n
SET
\r\n
$3
\r\n
foo
\r\n
$3
\r\n
bar
\r\n
"
,
len
)
==
0
&&
len
==
4
+
4
+
(
3
+
2
)
+
4
+
(
3
+
2
)
+
4
+
(
3
+
2
));
sdsfree
(
sds_cmd
);
sds_cmd
=
sdsempty
();
test
(
"Format command into sds by passing argc/argv with lengths: "
);
len
=
redisFormatSdsCommandArgv
(
&
sds_cmd
,
argc
,
argv
,
lens
);
test_cond
(
strncmp
(
sds_cmd
,
"*3
\r\n
$3
\r\n
SET
\r\n
$7
\r\n
foo
\0
xxx
\r\n
$3
\r\n
bar
\r\n
"
,
len
)
==
0
&&
len
==
4
+
4
+
(
3
+
2
)
+
4
+
(
7
+
2
)
+
4
+
(
3
+
2
));
sdsfree
(
sds_cmd
);
}
static
void
test_append_formatted_commands
(
struct
config
config
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment