From 254c9a6e9d68df0bd2970f83a92aa31662bc6edf Mon Sep 17 00:00:00 2001 From: Mathis Rosenhauer Date: Tue, 13 Nov 2012 13:55:16 +0100 Subject: [PATCH] run checks with small and with large buffers --- tests/check_code_options.c | 78 ++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/tests/check_code_options.c b/tests/check_code_options.c index de8dce1..fbbff24 100644 --- a/tests/check_code_options.c +++ b/tests/check_code_options.c @@ -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); -- 2.7.4