Commit ee443ce5 authored by Pieter Noordhuis's avatar Pieter Noordhuis
Browse files

Use 3 slices in the segmented data test

parent 45ed2729
...@@ -128,12 +128,13 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) { ...@@ -128,12 +128,13 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) {
log_entry_t *ref; log_entry_t *ref;
redis_parser_t *p; redis_parser_t *p;
redis_protocol_t *res; redis_protocol_t *res;
size_t i, j; size_t i, j, k;
ref = dup_cb_log(); ref = dup_cb_log();
p = malloc(sizeof(redis_parser_t)); p = malloc(sizeof(redis_parser_t));
for (i = 1; i < (len-1); i++) { for (i = 0; i < (len-2); i++) {
for (j = i+1; j < (len-1); j++) {
RESET_PARSER_T(p); RESET_PARSER_T(p);
/* Slice 1 */ /* Slice 1 */
...@@ -141,13 +142,17 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) { ...@@ -141,13 +142,17 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) {
assert(NULL == res); /* no result */ assert(NULL == res); /* no result */
/* Slice 2 */ /* Slice 2 */
assert_equal_size_t(redis_parser_execute(p, &res, buf+i, len-i), len-i); assert_equal_size_t(redis_parser_execute(p, &res, buf+i, j-i), j-i);
assert(NULL == res); /* no result */
/* Slice 3 */
assert_equal_size_t(redis_parser_execute(p, &res, buf+j, len-j), len-j);
assert(NULL != res); assert(NULL != res);
/* Compare callback log with reference */ /* Compare callback log with reference */
for (j = 0; j < CB_LOG_SIZE; j++) { for (k = 0; k < CB_LOG_SIZE; k++) {
log_entry_t expect = ref[j]; log_entry_t expect = ref[k];
log_entry_t actual = cb_log[j]; log_entry_t actual = cb_log[k];
/* Not interested in the redis_protocol_t data */ /* Not interested in the redis_protocol_t data */
memset(&expect.obj, 0, sizeof(expect.obj)); memset(&expect.obj, 0, sizeof(expect.obj));
...@@ -155,6 +160,7 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) { ...@@ -155,6 +160,7 @@ void test_char_by_char(redis_protocol_t *_unused, const char *buf, size_t len) {
assert(memcmp(&expect, &actual, sizeof(expect)) == 0); assert(memcmp(&expect, &actual, sizeof(expect)) == 0);
} }
} }
}
free(p); free(p);
free(ref); free(ref);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment