expand test to include simplified for of specification
This commit is contained in:
parent
9a486217b7
commit
8a95ba64c1
@ -64,11 +64,18 @@ static FLAC__bool failed_(const char *msg)
|
||||
return false;
|
||||
}
|
||||
|
||||
static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, const char *res)
|
||||
static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, const char *res, FLAC__bool fn_only)
|
||||
{
|
||||
FLAC__StreamMetadata *obj;
|
||||
const char *error;
|
||||
char s[4096];
|
||||
if(fn_only)
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
_snprintf(s, sizeof(s)-1, "%s/%s", prefix, pf->path);
|
||||
#else
|
||||
snprintf(s, sizeof(s)-1, "%s/%s", prefix, pf->path);
|
||||
#endif
|
||||
else
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
_snprintf(s, sizeof(s)-1, "%u|%s|%s|%s|%s/%s", (unsigned)pf->type, pf->mime_type, pf->description, res, prefix, pf->path);
|
||||
#else
|
||||
@ -92,7 +99,7 @@ static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, co
|
||||
obj->data.picture.data_length
|
||||
);
|
||||
}
|
||||
if(obj->data.picture.type != pf->type)
|
||||
if(obj->data.picture.type != (fn_only? FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER : pf->type))
|
||||
return failed_("picture type mismatch");
|
||||
if(strcmp(obj->data.picture.mime_type, pf->mime_type))
|
||||
return failed_("picture MIME type mismatch");
|
||||
@ -179,16 +186,21 @@ static FLAC__bool do_picture(const char *prefix)
|
||||
printf("OK\n");
|
||||
FLAC__metadata_object_delete(obj);
|
||||
|
||||
/* test automatic parsing of picture files from only the file name */
|
||||
for(i = 0; i < sizeof(picturefiles)/sizeof(picturefiles[0]); i++)
|
||||
if(!test_one_picture(prefix, picturefiles+i, "", /*fn_only=*/true))
|
||||
return false;
|
||||
|
||||
/* test automatic parsing of picture files to get resolution/color info */
|
||||
for(i = 0; i < sizeof(picturefiles)/sizeof(picturefiles[0]); i++)
|
||||
if(!test_one_picture(prefix, picturefiles+i, ""))
|
||||
if(!test_one_picture(prefix, picturefiles+i, "", /*fn_only=*/false))
|
||||
return false;
|
||||
|
||||
picturefiles[0].width = 320;
|
||||
picturefiles[0].height = 240;
|
||||
picturefiles[0].depth = 3;
|
||||
picturefiles[0].colors = 2;
|
||||
if(!test_one_picture(prefix, picturefiles+0, "320x240x3/2"))
|
||||
if(!test_one_picture(prefix, picturefiles+0, "320x240x3/2", /*fn_only=*/false))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
+++ grabbag unit test: picture
|
||||
|
||||
testing grabbag__picture_parse_specification("")... OK (failed as expected, error: invalid picture specification)
|
||||
testing grabbag__picture_parse_specification("||||")... OK (failed as expected: invalid MIME type)
|
||||
testing grabbag__picture_parse_specification("")... OK (failed as expected, error: error opening picture file)
|
||||
testing grabbag__picture_parse_specification("||||")... OK (failed as expected: error opening picture file)
|
||||
testing grabbag__picture_parse_specification("|image/gif|||")... OK (failed as expected: error opening picture file)
|
||||
testing grabbag__picture_parse_specification("|image/gif|desc|320|0.gif")... OK (failed as expected: invalid picture specification: can't parse resolution/color part)
|
||||
testing grabbag__picture_parse_specification("|image/gif|desc|320x240|0.gif")... OK (failed as expected: invalid picture specification: can't parse resolution/color part)
|
||||
@ -11,6 +11,20 @@ testing grabbag__picture_parse_specification("|image/gif|desc|320x240x9/2345|0.g
|
||||
testing grabbag__picture_parse_specification("1|-->|desc|32x24x9|0.gif")... OK (failed as expected: type 1 icon must be a 32x32 pixel PNG)
|
||||
testing grabbag__picture_parse_specification("|-->|desc||http://blah.blah.blah/z.gif")... OK (failed as expected: unable to extract resolution and color info from URL, user must set explicitly)
|
||||
testing grabbag__picture_parse_specification("|-->|desc|320x240x9|http://blah.blah.blah/z.gif")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/0.gif")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/1.gif")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/2.gif")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/0.jpg")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/4.jpg")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/0.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/1.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/2.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/3.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/4.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/5.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/6.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/7.png")... OK
|
||||
testing grabbag__picture_parse_specification("pictures/8.png")... OK
|
||||
testing grabbag__picture_parse_specification("3|image/gif|||pictures/0.gif")... OK
|
||||
testing grabbag__picture_parse_specification("4|image/gif|||pictures/1.gif")... OK
|
||||
testing grabbag__picture_parse_specification("0|image/gif|||pictures/2.gif")... OK
|
||||
|
Loading…
x
Reference in New Issue
Block a user