Closed schwehr closed 4 months ago
Not implying that you need to or should switch, but in case you ever want to switch to googletest, here is my initial port of check_long_fs. My suggested cleanups of the existing check_long_fs.c are in #8
check_long_fs.c
// TODO(schwehr): Document what this test does and how. #include <cstddef> #include <cstdlib> #include <vector> #include "testing/base/public/gunit.h" #include "check_aec.h" #include "libaec.h" namespace { bool check_long_fs(struct test_state *state) { const int size = state->bytes_per_sample; const int bs = state->strm->block_size; for (int i = 0; i < bs / 2; i++) { state->out(state->ubuf + size * i, state->xmin, size); state->out(state->ubuf + bs * size / 2 + size * i, 65000, size); } return state->codec(state) == 0; } TEST(LongFsTest, All) { constexpr size_t kBufferSize = 64 * 4; test_state state; state.dump = 0; state.buf_len = kBufferSize; state.ibuf_len = kBufferSize; state.cbuf_len = 2 * kBufferSize; std::vector<unsigned char> ubuf(state.buf_len); std::vector<unsigned char> cbuf(state.cbuf_len); std::vector<unsigned char> obuf(state.buf_len); state.ubuf = &ubuf[0]; state.cbuf = &cbuf[0]; state.obuf = &obuf[0]; aec_stream strm; strm.flags = AEC_DATA_PREPROCESS; state.strm = &strm; strm.bits_per_sample = 16; strm.block_size = 64; strm.rsi = 1; state.codec = encode_decode_large; update_state(&state); EXPECT_TRUE(check_long_fs(&state)); } } // namespace
And an update to check_aec.h, so that it is safe to call the functions from C++.
#ifdef __cplusplus extern "C" { #endif int update_state(struct test_state *state); int encode_decode_small(struct test_state *state); int encode_decode_large(struct test_state *state); #ifdef __cplusplus } // extern "C" #endif
Thanks Kurt, I will certainly consider this.
Not implying that you need to or should switch, but in case you ever want to switch to googletest, here is my initial port of check_long_fs. My suggested cleanups of the existing
check_long_fs.c
are in #8And an update to check_aec.h, so that it is safe to call the functions from C++.