History

fate/imf: remove redundant code

Pierre-Anthony Lemieux committed 3 years ago

Commit 28381381 parent dbe43bc1 file · +12 −40Browse files

Unified · Split

libavformat/tests/imf.c+12−40
@@ -257,7 +257,7 @@ const char *cpl_doc = · 256 unmodified lines
257257 "</SegmentList>"
258258 "</CompositionPlaylist>";
259259
260−const char *cpl_bad_doc = "<Composition></Composition>";
260+const char *cpl_bad_empty_doc = "<Composition></Composition>";
261261
262262 const char *asset_map_doc =
263263 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
@@ -384,52 +384,31 @@ static int test_cpl_parsing(void) · 120 unmodified lines
384384 return 0;
385385 }
386386
387−static int test_bad_cpl_parsing(FFIMFCPL **cpl)
388−{
389− xmlDocPtr doc;
390− int ret;
391−
392− doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0);
393− if (doc == NULL) {
394− printf("XML parsing failed.\n");
395− return 1;
396− }
397−
398− ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl);
399− xmlFreeDoc(doc);
400− if (ret) {
401− printf("CPL parsing failed.\n");
402− return ret;
403− }
404−
405− ff_imf_cpl_free(*cpl);
406− *cpl = NULL;
407−
408− return 0;
409−}
410−
411−static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl)
412−{
387+static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pass) {
413388 xmlDocPtr doc;
414389 int ret;
415390
416− doc = xmlReadMemory(cpl_bad_resource_doc, strlen(cpl_bad_resource_doc), NULL, NULL, 0);
391+ doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0);
417392 if (doc == NULL) {
418393 printf("XML parsing failed.\n");
419− return 1;
394+ return should_pass;
420395 }
421396
422397 ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl);
423398 xmlFreeDoc(doc);
424399 if (ret) {
425400 printf("CPL parsing failed.\n");
426− return ret;
401+ if (*cpl) {
402+ printf("Improper cleanup after failed CPL parsing\n");
403+ return 1;
404+ }
405+ return should_pass;
427406 }
428407
429408 ff_imf_cpl_free(*cpl);
430409 *cpl = NULL;
431410
432− return 0;
411+ return !should_pass;
433412 }
434413
435414 static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset)
@@ -591,20 +570,13 @@ int main(int argc, char *argv[]) · 155 unmodified lines
591570 ret = 1;
592571
593572 printf("#### The following should fail ####\n");
594− if (test_bad_cpl_parsing(&cpl) == 0) {
573+ if (test_cpl_from_doc(&cpl, cpl_bad_empty_doc, 0) != 0)
595574 ret = 1;
596− } else if (cpl) {
597− printf("Improper cleanup after failed CPL parsing\n");
598− ret = 1;
599− }
600575 printf("#### End failing test ####\n");
601576
602577 printf("#### The following should emit errors ####\n");
603− if (test_bad_resource_cpl_parsing(&cpl) != 0) {
604− if (cpl)
605− printf("Improper cleanup after failed CPL parsing\n");
578+ if (test_cpl_from_doc(&cpl, cpl_bad_resource_doc, 1) != 0)
606579 ret = 1;
607− }
608580 printf("#### End emission of errors ####\n");
609581
610582 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t