X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=tests%2Funit%2Ftestempty1.c;h=fc961c22d574ff8219ae2c9e8eb8feb52493be5e;hb=7aece5e8e7d4214d140a45aca50a824ff8092924;hp=17d16a17df222bfd4424b5ef741402a9b0ac29d2;hpb=af58e8e8f9d08c1e276a9ba070eb4d44a6ca4950;p=openjpeg.git diff --git a/tests/unit/testempty1.c b/tests/unit/testempty1.c index 17d16a17..fc961c22 100644 --- a/tests/unit/testempty1.c +++ b/tests/unit/testempty1.c @@ -39,7 +39,7 @@ void info_callback(const char *msg, void *v); void error_callback(const char *msg, void *v) { (void)msg; (void)v; -assert(0); +puts(msg); } void warning_callback(const char *msg, void *v) { (void)msg; @@ -57,15 +57,15 @@ int main(int argc, char *argv[]) const char * v = opj_version(); const OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_GRAY; - int numcomps = 1; - int i; - int image_width = 256; - int image_height = 256; + unsigned int numcomps = 1; + unsigned int i; + unsigned int image_width = 256; + unsigned int image_height = 256; opj_cparameters_t parameters; - int subsampling_dx = 0; - int subsampling_dy = 0; + unsigned int subsampling_dx = 0; + unsigned int subsampling_dy = 0; opj_image_cmptparm_t cmptparm; opj_image_t *image; @@ -91,17 +91,17 @@ int main(int argc, char *argv[]) for (i = 0; i < image_width * image_height; i++) { - int compno; + unsigned int compno; for(compno = 0; compno < numcomps; compno++) { image->comps[compno].data[i] = 0; } } - /* catch events using our callbacks and give a local context */ - opj_set_info_handler(l_codec, info_callback,00); - opj_set_warning_handler(l_codec, warning_callback,00); - opj_set_error_handler(l_codec, error_callback,00); + /* catch events using our callbacks and give a local context */ + opj_set_info_handler(l_codec, info_callback,00); + opj_set_warning_handler(l_codec, warning_callback,00); + opj_set_error_handler(l_codec, error_callback,00); l_codec = opj_create_compress(OPJ_CODEC_J2K); opj_set_info_handler(l_codec, info_callback,00); @@ -110,9 +110,16 @@ int main(int argc, char *argv[]) opj_setup_encoder(l_codec, ¶meters, image); - l_stream = opj_stream_create_default_file_stream_v3("testempty1.j2k",OPJ_FALSE); + l_stream = opj_stream_create_default_file_stream("testempty1.j2k",OPJ_FALSE); assert(l_stream); bSuccess = opj_start_compress(l_codec,image,l_stream); + if( !bSuccess ) + { + opj_stream_destroy(l_stream); + opj_destroy_codec(l_codec); + opj_image_destroy(image); + return 0; + } assert( bSuccess ); bSuccess = opj_encode(l_codec, l_stream); @@ -120,7 +127,7 @@ int main(int argc, char *argv[]) bSuccess = opj_end_compress(l_codec, l_stream); assert( bSuccess ); - opj_stream_destroy_v3(l_stream); + opj_stream_destroy(l_stream); opj_destroy_codec(l_codec); opj_image_destroy(image);