Commit 254c9a6e authored by Mathis Rosenhauer's avatar Mathis Rosenhauer Committed by Thomas Jahns

run checks with small and with large buffers

parent 488d5431
......@@ -192,63 +192,81 @@ int check_bps(struct test_state *state)
return 0;
}
int main (void)
int check_byte_orderings(struct test_state *state)
{
int status;
struct aec_stream strm;
struct test_state state;
state.buf_len = state.ibuf_len = BUF_SIZE;
state.cbuf_len = 2 * BUF_SIZE;
state.ubuf = (unsigned char *)malloc(state.buf_len);
state.cbuf = (unsigned char *)malloc(state.cbuf_len);
state.obuf = (unsigned char *)malloc(state.buf_len);
if (!state.ubuf || !state.cbuf || !state.obuf) {
printf("Not enough memory.\n");
return 99;
}
strm.flags = AEC_DATA_PREPROCESS;
state.strm = &strm;
state.codec = encode_decode_small;
printf("----------------------------\n");
printf("Checking LSB first, unsigned\n");
printf("----------------------------\n");
status = check_bps(&state);
status = check_bps(state);
if (status)
goto DESTRUCT;
return status;
printf("--------------------------\n");
printf("Checking LSB first, signed\n");
printf("--------------------------\n");
strm.flags |= AEC_DATA_SIGNED;
state->strm->flags |= AEC_DATA_SIGNED;
status = check_bps(&state);
status = check_bps(state);
if (status)
goto DESTRUCT;
return status;
strm.flags &= ~AEC_DATA_SIGNED;
strm.flags |= AEC_DATA_MSB;
state->strm->flags &= ~AEC_DATA_SIGNED;
state->strm->flags |= AEC_DATA_MSB;
printf("----------------------------\n");
printf("Checking MSB first, unsigned\n");
printf("----------------------------\n");
status = check_bps(&state);
status = check_bps(state);
if (status)
goto DESTRUCT;
return status;
printf("--------------------------\n");
printf("Checking MSB first, signed\n");
printf("--------------------------\n");
strm.flags |= AEC_DATA_SIGNED;
state->strm->flags |= AEC_DATA_SIGNED;
status = check_bps(state);
if (status)
return status;
}
int main (void)
{
int status;
struct aec_stream strm;
struct test_state state;
state.buf_len = state.ibuf_len = BUF_SIZE;
state.cbuf_len = 2 * BUF_SIZE;
state.ubuf = (unsigned char *)malloc(state.buf_len);
state.cbuf = (unsigned char *)malloc(state.cbuf_len);
state.obuf = (unsigned char *)malloc(state.buf_len);
status = check_bps(&state);
if (!state.ubuf || !state.cbuf || !state.obuf) {
printf("Not enough memory.\n");
return 99;
}
strm.flags = AEC_DATA_PREPROCESS;
state.strm = &strm;
printf("***************************\n");
printf("Checking with small buffers\n");
printf("***************************\n");
state.codec = encode_decode_small;
status = check_byte_orderings(&state);
if (status)
goto DESTRUCT;
printf("***************************\n");
printf("Checking with large buffers\n");
printf("***************************\n");
state.codec = encode_decode_large;
status = check_byte_orderings(&state);
DESTRUCT:
free(state.ubuf);
free(state.cbuf);
......
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