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
4ac55be9
Commit
4ac55be9
authored
Jul 09, 2011
by
Pieter Noordhuis
Browse files
Update printf-formatting tests to fail
parent
5def8643
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.c
View file @
4ac55be9
...
...
@@ -142,16 +142,18 @@ static void test_format_commands(void) {
len
==
4
+
4
+
(
3
+
2
)
+
4
+
(
1
+
2
)
+
4
+
(
1
+
2
));
free
(
cmd
);
/* sizeof(long long) is 8 bytes regardless of architecture */
test
(
"Format command with printf-delegation (long long): "
);
len
=
redisFormatCommand
(
&
cmd
,
"key:%08lld"
,
1234ll
);
test_cond
(
strncmp
(
cmd
,
"*
1
\r\n
$12
\r\n
key:00001234
\r\n
"
,
len
)
==
0
&&
len
==
4
+
5
+
(
12
+
2
));
len
=
redisFormatCommand
(
&
cmd
,
"key:%08lld
str:%s
"
,
1234ll
,
"hello"
);
test_cond
(
strncmp
(
cmd
,
"*
2
\r\n
$12
\r\n
key:00001234
\r\n
$9
\r\n
str:hello
\r\n
"
,
len
)
==
0
&&
len
==
4
+
5
+
(
12
+
2
)
+
4
+
(
9
+
2
)
);
free
(
cmd
);
/* sizeof(float) is 4 bytes regardless of architecture */
test
(
"Format command with printf-delegation (float): "
);
len
=
redisFormatCommand
(
&
cmd
,
"v:%06.1f"
,
12
.
34
f
);
test_cond
(
strncmp
(
cmd
,
"*
1
\r\n
$8
\r\n
v:0012.3
\r\n
"
,
len
)
==
0
&&
len
==
4
+
4
+
(
8
+
2
));
len
=
redisFormatCommand
(
&
cmd
,
"v:%06.1f
str:%s
"
,
12
.
34
f
,
"hello"
);
test_cond
(
strncmp
(
cmd
,
"*
2
\r\n
$8
\r\n
v:0012.3
\r\n
$9
\r\n
str:hello
\r\n
"
,
len
)
==
0
&&
len
==
4
+
4
+
(
8
+
2
)
+
4
+
(
9
+
2
)
);
free
(
cmd
);
test
(
"Format command with printf-delegation and extra interpolation: "
);
...
...
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