Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
d128380b
Commit
d128380b
authored
Jun 30, 2011
by
Pieter Noordhuis
Browse files
Basic integer type tests
parent
4ae503d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
parser.c
View file @
d128380b
...
...
@@ -265,7 +265,9 @@ size_t redis_parser_execute(redis_parser_t *parser, redis_protocol_t **dst, cons
goto
done
;
l_integer_lf_integer_t:
/* Any integer is OK */
/* Setup content offset and length */
cur
->
coff
=
cur
->
poff
+
1
;
cur
->
clen
=
nread
-
cur
->
coff
-
1
;
/* remove \r */
CALLBACK
(
integer
,
i64
);
goto
done
;
}
...
...
test/parser.c
View file @
d128380b
...
...
@@ -185,8 +185,36 @@ void test_array(void) {
free_parser
(
p
);
}
void
test_integer
(
void
)
{
redis_parser_t
*
p
=
new_parser
();
redis_protocol_t
*
res
;
const
char
*
buf
=
":1234
\r\n
"
;
size_t
len
=
7
;
/* Parse and check resulting protocol_t */
reset_cb_log
();
assert
(
redis_parser_execute
(
p
,
&
res
,
buf
,
len
)
==
len
);
assert
(
res
!=
NULL
);
assert
(
res
->
type
==
REDIS_INTEGER_T
);
assert
(
res
->
poff
==
0
);
assert
(
res
->
plen
==
7
);
assert
(
res
->
coff
==
1
);
assert
(
res
->
clen
==
4
);
/* Check callbacks */
assert
(
cb_log_idx
==
1
);
assert
(
cb_log
[
0
].
integer_value
==
1234
);
/* Chunked check */
test_char_by_char
(
res
,
buf
,
len
);
free_parser
(
p
);
}
int
main
(
int
argc
,
char
**
argv
)
{
test_string
();
test_array
();
test_integer
();
return
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