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
ee443ce5
Commit
ee443ce5
authored
Jul 12, 2011
by
Pieter Noordhuis
Browse files
Use 3 slices in the segmented data test
parent
45ed2729
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/parser.c
View file @
ee443ce5
...
...
@@ -128,31 +128,37 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) {
log_entry_t
*
ref
;
redis_parser_t
*
p
;
redis_protocol_t
*
res
;
size_t
i
,
j
;
size_t
i
,
j
,
k
;
ref
=
dup_cb_log
();
p
=
malloc
(
sizeof
(
redis_parser_t
));
for
(
i
=
1
;
i
<
(
len
-
1
);
i
++
)
{
RESET_PARSER_T
(
p
);
for
(
i
=
0
;
i
<
(
len
-
2
);
i
++
)
{
for
(
j
=
i
+
1
;
j
<
(
len
-
1
);
j
++
)
{
RESET_PARSER_T
(
p
);
/* Slice 1 */
assert_equal_size_t
(
redis_parser_execute
(
p
,
&
res
,
buf
,
i
),
i
);
assert
(
NULL
==
res
);
/* no result */
/* Slice 1 */
assert_equal_size_t
(
redis_parser_execute
(
p
,
&
res
,
buf
,
i
),
i
);
assert
(
NULL
==
res
);
/* no result */
/* Slice 2 */
assert_equal_size_t
(
redis_parser_execute
(
p
,
&
res
,
buf
+
i
,
len
-
i
),
len
-
i
);
assert
(
NULL
!
=
res
);
/* Slice 2 */
assert_equal_size_t
(
redis_parser_execute
(
p
,
&
res
,
buf
+
i
,
j
-
i
),
j
-
i
);
assert
(
NULL
=
=
res
);
/* no result */
/* Compare callback log with reference */
for
(
j
=
0
;
j
<
CB_LOG_SIZE
;
j
++
)
{
log_entry_t
expect
=
ref
[
j
];
log_entry_t
actual
=
cb_log
[
j
];
/* Slice 3 */
assert_equal_size_t
(
redis_parser_execute
(
p
,
&
res
,
buf
+
j
,
len
-
j
),
len
-
j
);
assert
(
NULL
!=
res
);
/* Not interested in the redis_protocol_t data */
memset
(
&
expect
.
obj
,
0
,
sizeof
(
expect
.
obj
));
memset
(
&
actual
.
obj
,
0
,
sizeof
(
actual
.
obj
));
assert
(
memcmp
(
&
expect
,
&
actual
,
sizeof
(
expect
))
==
0
);
/* Compare callback log with reference */
for
(
k
=
0
;
k
<
CB_LOG_SIZE
;
k
++
)
{
log_entry_t
expect
=
ref
[
k
];
log_entry_t
actual
=
cb_log
[
k
];
/* Not interested in the redis_protocol_t data */
memset
(
&
expect
.
obj
,
0
,
sizeof
(
expect
.
obj
));
memset
(
&
actual
.
obj
,
0
,
sizeof
(
actual
.
obj
));
assert
(
memcmp
(
&
expect
,
&
actual
,
sizeof
(
expect
))
==
0
);
}
}
}
...
...
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