mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
expand test to include simplified for of specification
This commit is contained in:
@@ -64,15 +64,22 @@ static FLAC__bool failed_(const char *msg)
|
|||||||
return false;
|
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;
|
FLAC__StreamMetadata *obj;
|
||||||
const char *error;
|
const char *error;
|
||||||
char s[4096];
|
char s[4096];
|
||||||
|
if(fn_only)
|
||||||
#if defined _MSC_VER || defined __MINGW32__
|
#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);
|
_snprintf(s, sizeof(s)-1, "%s/%s", prefix, pf->path);
|
||||||
#else
|
#else
|
||||||
snprintf(s, sizeof(s)-1, "%u|%s|%s|%s|%s/%s", (unsigned)pf->type, pf->mime_type, pf->description, res, prefix, pf->path);
|
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
|
||||||
|
snprintf(s, sizeof(s)-1, "%u|%s|%s|%s|%s/%s", (unsigned)pf->type, pf->mime_type, pf->description, res, prefix, pf->path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("testing grabbag__picture_parse_specification(\"%s\")... ", s);
|
printf("testing grabbag__picture_parse_specification(\"%s\")... ", s);
|
||||||
@@ -92,7 +99,7 @@ static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, co
|
|||||||
obj->data.picture.data_length
|
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");
|
return failed_("picture type mismatch");
|
||||||
if(strcmp(obj->data.picture.mime_type, pf->mime_type))
|
if(strcmp(obj->data.picture.mime_type, pf->mime_type))
|
||||||
return failed_("picture MIME type mismatch");
|
return failed_("picture MIME type mismatch");
|
||||||
@@ -179,16 +186,21 @@ static FLAC__bool do_picture(const char *prefix)
|
|||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
FLAC__metadata_object_delete(obj);
|
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 */
|
/* test automatic parsing of picture files to get resolution/color info */
|
||||||
for(i = 0; i < sizeof(picturefiles)/sizeof(picturefiles[0]); i++)
|
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;
|
return false;
|
||||||
|
|
||||||
picturefiles[0].width = 320;
|
picturefiles[0].width = 320;
|
||||||
picturefiles[0].height = 240;
|
picturefiles[0].height = 240;
|
||||||
picturefiles[0].depth = 3;
|
picturefiles[0].depth = 3;
|
||||||
picturefiles[0].colors = 2;
|
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 false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
+++ grabbag unit test: picture
|
+++ 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, error: error opening picture file)
|
||||||
testing grabbag__picture_parse_specification("||||")... OK (failed as expected: invalid MIME type)
|
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|||")... 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|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)
|
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("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||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("|-->|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("3|image/gif|||pictures/0.gif")... OK
|
||||||
testing grabbag__picture_parse_specification("4|image/gif|||pictures/1.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
|
testing grabbag__picture_parse_specification("0|image/gif|||pictures/2.gif")... OK
|
||||||
|
|||||||
Reference in New Issue
Block a user