use expect macro in existing tests

This commit is contained in:
alexey.lysiuk 2021-05-17 10:28:55 +03:00
parent bc866fdd9d
commit fa1727f8ec
4 changed files with 14 additions and 63 deletions

View File

@ -2,22 +2,11 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
if (mpg123_init() != MPG123_OK) AEDI_EXPECT(mpg123_init() == MPG123_OK);
{
return 1;
}
mpg123_handle* mh = mpg123_new(NULL, NULL); mpg123_handle* mh = mpg123_new(NULL, NULL);
AEDI_EXPECT(mh != nullptr);
if (mh == nullptr) AEDI_EXPECT(mpg123_param(mh, MPG123_VERBOSE, 1, 0.) == MPG123_OK);
{
return 1;
}
if (mpg123_param(mh, MPG123_VERBOSE, 1, 0.) != MPG123_OK)
{
return 1;
}
mpg123_delete(mh); mpg123_delete(mh);
mpg123_exit(); mpg123_exit();

View File

@ -2,10 +2,7 @@
int main() int main()
{ {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) AEDI_EXPECT(SDL_Init(SDL_INIT_EVERYTHING) == 0);
{
return 1;
}
SDL_Event dummy; SDL_Event dummy;

View File

@ -4,23 +4,11 @@
int main() int main()
{ {
vpx_codec_ctx_t codec; vpx_codec_ctx_t codec;
AEDI_EXPECT(vpx_codec_dec_init(&codec, &vpx_codec_vp8_dx_algo, nullptr, 0) == VPX_CODEC_OK);
if (vpx_codec_dec_init(&codec, &vpx_codec_vp8_dx_algo, nullptr, 0) != VPX_CODEC_OK)
{
return 1;
}
vp8_postproc_cfg_t pp = { 0, 0, 0 }; vp8_postproc_cfg_t pp = { 0, 0, 0 };
AEDI_EXPECT(vpx_codec_control(&codec, VP8_SET_POSTPROC, &pp) == VPX_CODEC_OK);
if (vpx_codec_control(&codec, VP8_SET_POSTPROC, &pp) != VPX_CODEC_OK) AEDI_EXPECT(vpx_codec_destroy(&codec) == VPX_CODEC_OK);
{
return 1;
}
if (vpx_codec_destroy(&codec) != VPX_CODEC_OK)
{
return 1;
}
return 0; return 0;
} }

View File

@ -5,10 +5,7 @@ int main()
{ {
z_stream stream = {}; z_stream stream = {};
if (deflateInit(&stream, Z_DEFAULT_COMPRESSION) != Z_OK) AEDI_EXPECT(deflateInit(&stream, Z_DEFAULT_COMPRESSION) == Z_OK);
{
return 1;
}
constexpr size_t BUFFER_SIZE = 1024; constexpr size_t BUFFER_SIZE = 1024;
unsigned char reference[BUFFER_SIZE]; unsigned char reference[BUFFER_SIZE];
@ -25,22 +22,12 @@ int main()
stream.next_out = deflated; stream.next_out = deflated;
stream.avail_out = BUFFER_SIZE; stream.avail_out = BUFFER_SIZE;
if (deflate(&stream, Z_FINISH) != Z_STREAM_END) AEDI_EXPECT(deflate(&stream, Z_FINISH) == Z_STREAM_END);
{ AEDI_EXPECT(deflateEnd(&stream) == Z_OK);
return 1;
}
if (deflateEnd(&stream) != Z_OK)
{
return 1;
}
stream = {}; stream = {};
if (inflateInit(&stream) != Z_OK) AEDI_EXPECT(inflateInit(&stream) == Z_OK);
{
return 1;
}
unsigned char inflated[BUFFER_SIZE] = {}; unsigned char inflated[BUFFER_SIZE] = {};
@ -49,20 +36,10 @@ int main()
stream.next_out = inflated; stream.next_out = inflated;
stream.avail_out = BUFFER_SIZE; stream.avail_out = BUFFER_SIZE;
if (inflate(&stream, Z_FINISH) != Z_STREAM_END) AEDI_EXPECT(inflate(&stream, Z_FINISH) == Z_STREAM_END);
{ AEDI_EXPECT(inflateEnd(&stream) == Z_OK);
return 1;
}
if (inflateEnd(&stream) != Z_OK) AEDI_EXPECT(memcmp(reference, inflated, BUFFER_SIZE) == 0);
{
return 1;
}
if (memcmp(reference, inflated, BUFFER_SIZE) != 0)
{
return 1;
}
return 0; return 0;
} }