/* $Id: cpl_pluginlist-test.c,v 1.5 2007/07/16 09:09:04 llundin Exp $ * * This file is part of the ESO Common Pipeline Library * Copyright (C) 2001-2004 European Southern Observatory * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * $Author: llundin $ * $Date: 2007/07/16 09:09:04 $ * $Revision: 1.5 $ * $Name: $ */ #undef CX_DISABLE_ASSERT #undef CX_LOG_DOMAIN #include #include #include #include "cpl_init.h" #include "cpl_plugin.h" #include "cpl_pluginlist.h" int main(void) { cpl_plugin *pl1 = NULL, *pl2 = NULL, *pl3 = NULL, *pl4 = NULL, *pl5 = NULL, *front = NULL, *back = NULL, *search = NULL; cpl_pluginlist *pllst = NULL; int list_size = 5; cpl_init(CPL_INIT_DEFAULT); pl1 = cpl_plugin_new(); cpl_plugin_init(pl1, 1, 10000, (unsigned long) CPL_PLUGIN_TYPE_RECIPE, "cmdlcaller.test.plgn1", "synopsis1", "description1", "mkiesgen", "mkiesgen@eso.org", "copyright and license text", NULL, NULL, NULL); if (pl1==NULL) { cpl_end(); return 1; } pl2 = cpl_plugin_new(); cpl_plugin_init(pl2, 1, 10000, (unsigned long) CPL_PLUGIN_TYPE_RECIPE, "cmdlcaller.test.plgn2", "synopsis2", "description2", "mkiesgen", "mkiesgen@eso.org", "copyright and license text", NULL, NULL, NULL); if (pl2==NULL) { cpl_plugin_delete(pl1); cpl_end(); return 1; } pl3 = cpl_plugin_new(); cpl_plugin_init(pl3, 1, 10000, (unsigned long) CPL_PLUGIN_TYPE_RECIPE, "cmdlcaller.test.plgn3", "synopsis3", "description3", "mkiesgen", "mkiesgen@eso.org", "copyright and license text", NULL, NULL, NULL); if (pl3==NULL) { cpl_plugin_delete(pl2); cpl_plugin_delete(pl1); cpl_end(); return 1; } pl4 = cpl_plugin_new(); cpl_plugin_init(pl4, 1, 10000, (unsigned long) CPL_PLUGIN_TYPE_RECIPE, "cmdlcaller.test.plgn4", "synopsis4", "description4", "mkiesgen", "mkiesgen@eso.org", "copyright and license text", NULL, NULL, NULL); if (pl4==NULL) { cpl_plugin_delete(pl3); cpl_plugin_delete(pl2); cpl_plugin_delete(pl1); cpl_end(); return 1; } pl5 = cpl_plugin_new(); cpl_plugin_init(pl5, 1, 10000, (unsigned long) CPL_PLUGIN_TYPE_RECIPE, "cmdlcaller.test.plgn5", "synopsis5", "description5", "mkiesgen", "mkiesgen@eso.org", "copyright and license text", NULL, NULL, NULL); if (pl5==NULL) { cpl_plugin_delete(pl4); cpl_plugin_delete(pl3); cpl_plugin_delete(pl2); cpl_plugin_delete(pl1); cpl_end(); return 1; } pllst = cpl_pluginlist_new(); if (pllst == NULL) { cpl_end(); return 1; } /* * After appending and prepending the ordering of the plugins * is like this: 4 5 1 3 2 */ cpl_pluginlist_append(pllst, pl1); cpl_pluginlist_append(pllst, pl3); cpl_pluginlist_append(pllst, pl2); cpl_pluginlist_prepend(pllst, pl5); cpl_pluginlist_prepend(pllst, pl4); /* * */ if (cpl_pluginlist_get_size(pllst)!=list_size) { cpl_pluginlist_delete(pllst); cpl_end(); return 1; } front = cpl_pluginlist_get_first(pllst); back = cpl_pluginlist_get_last(pllst); if (strcmp(cpl_plugin_get_name(front),"cmdlcaller.test.plgn4")!=0) { cpl_pluginlist_delete(pllst); cpl_end(); return 1; } if (strcmp(cpl_plugin_get_name(back),"cmdlcaller.test.plgn2")!=0) { cpl_pluginlist_delete(pllst); cpl_end(); return 1; } search = cpl_pluginlist_find(pllst, "cmdlcaller.test.plgn2"); if (strcmp(cpl_plugin_get_description(search),"description2")!=0) { cpl_pluginlist_delete(pllst); cpl_end(); return 1; } cpl_pluginlist_delete(pllst); cpl_end(); return 0; }