From fa1727f8ec21478cad1171664cf806348d16a50c Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 17 May 2021 10:28:55 +0300 Subject: [PATCH] use expect macro in existing tests --- test/libmpg123.cpp | 17 +++-------------- test/sdl2.cpp | 5 +---- test/vpx.cpp | 18 +++--------------- test/zlib.cpp | 37 +++++++------------------------------ 4 files changed, 14 insertions(+), 63 deletions(-) diff --git a/test/libmpg123.cpp b/test/libmpg123.cpp index 75aa0c25..5b08f92c 100644 --- a/test/libmpg123.cpp +++ b/test/libmpg123.cpp @@ -2,22 +2,11 @@ int main(int argc, char **argv) { - if (mpg123_init() != MPG123_OK) - { - return 1; - } + AEDI_EXPECT(mpg123_init() == MPG123_OK); mpg123_handle* mh = mpg123_new(NULL, NULL); - - if (mh == nullptr) - { - return 1; - } - - if (mpg123_param(mh, MPG123_VERBOSE, 1, 0.) != MPG123_OK) - { - return 1; - } + AEDI_EXPECT(mh != nullptr); + AEDI_EXPECT(mpg123_param(mh, MPG123_VERBOSE, 1, 0.) == MPG123_OK); mpg123_delete(mh); mpg123_exit(); diff --git a/test/sdl2.cpp b/test/sdl2.cpp index d5ec9680..ce312a8c 100644 --- a/test/sdl2.cpp +++ b/test/sdl2.cpp @@ -2,10 +2,7 @@ int main() { - if (SDL_Init(SDL_INIT_EVERYTHING) != 0) - { - return 1; - } + AEDI_EXPECT(SDL_Init(SDL_INIT_EVERYTHING) == 0); SDL_Event dummy; diff --git a/test/vpx.cpp b/test/vpx.cpp index e9189a1d..ba8c8fcc 100644 --- a/test/vpx.cpp +++ b/test/vpx.cpp @@ -4,23 +4,11 @@ int main() { vpx_codec_ctx_t codec; - - if (vpx_codec_dec_init(&codec, &vpx_codec_vp8_dx_algo, nullptr, 0) != VPX_CODEC_OK) - { - return 1; - } + AEDI_EXPECT(vpx_codec_dec_init(&codec, &vpx_codec_vp8_dx_algo, nullptr, 0) == VPX_CODEC_OK); vp8_postproc_cfg_t pp = { 0, 0, 0 }; - - if (vpx_codec_control(&codec, VP8_SET_POSTPROC, &pp) != VPX_CODEC_OK) - { - return 1; - } - - if (vpx_codec_destroy(&codec) != VPX_CODEC_OK) - { - return 1; - } + AEDI_EXPECT(vpx_codec_control(&codec, VP8_SET_POSTPROC, &pp) == VPX_CODEC_OK); + AEDI_EXPECT(vpx_codec_destroy(&codec) == VPX_CODEC_OK); return 0; } diff --git a/test/zlib.cpp b/test/zlib.cpp index 2ebaf772..88cc6657 100644 --- a/test/zlib.cpp +++ b/test/zlib.cpp @@ -5,10 +5,7 @@ int main() { z_stream stream = {}; - if (deflateInit(&stream, Z_DEFAULT_COMPRESSION) != Z_OK) - { - return 1; - } + AEDI_EXPECT(deflateInit(&stream, Z_DEFAULT_COMPRESSION) == Z_OK); constexpr size_t BUFFER_SIZE = 1024; unsigned char reference[BUFFER_SIZE]; @@ -25,22 +22,12 @@ int main() stream.next_out = deflated; stream.avail_out = BUFFER_SIZE; - if (deflate(&stream, Z_FINISH) != Z_STREAM_END) - { - return 1; - } - - if (deflateEnd(&stream) != Z_OK) - { - return 1; - } + AEDI_EXPECT(deflate(&stream, Z_FINISH) == Z_STREAM_END); + AEDI_EXPECT(deflateEnd(&stream) == Z_OK); stream = {}; - if (inflateInit(&stream) != Z_OK) - { - return 1; - } + AEDI_EXPECT(inflateInit(&stream) == Z_OK); unsigned char inflated[BUFFER_SIZE] = {}; @@ -49,20 +36,10 @@ int main() stream.next_out = inflated; stream.avail_out = BUFFER_SIZE; - if (inflate(&stream, Z_FINISH) != Z_STREAM_END) - { - return 1; - } + AEDI_EXPECT(inflate(&stream, Z_FINISH) == Z_STREAM_END); + AEDI_EXPECT(inflateEnd(&stream) == Z_OK); - if (inflateEnd(&stream) != Z_OK) - { - return 1; - } - - if (memcmp(reference, inflated, BUFFER_SIZE) != 0) - { - return 1; - } + AEDI_EXPECT(memcmp(reference, inflated, BUFFER_SIZE) == 0); return 0; }