X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ft13.c;h=40d41ca143e7ac1cf6090f26846a9bed2b75b0a5;hb=c401b3a1421e31b3d6b77bc7bac6ffb934207df1;hp=d390122521de0801949bd1f16c3fceb94d50475b;hpb=6c3da5ae754ebcd91827f61f1d402129fe379093;p=idzebra-moved-to-github.git diff --git a/test/api/t13.c b/test/api/t13.c index d390122..40d41ca 100644 --- a/test/api/t13.c +++ b/test/api/t13.c @@ -1,5 +1,5 @@ -/* $Id: t13.c,v 1.3 2005-09-13 13:15:24 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: t13.c,v 1.9 2006-08-14 10:40:22 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -15,17 +15,18 @@ 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 Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ /** test resources */ #include #include +#include "testlib.h" #include -void tst() +static void tst_res(void) { Res default_res; /* default resources */ Res temp_res; /* temporary resources */ @@ -35,29 +36,27 @@ void tst() int i; default_res = res_open(0, 0); /* completely empty */ - if (!default_res) - exit(1); + YAZ_CHECK(default_res); + res_set(default_res, "name1", "value1"); temp_res = res_open(0, 0); /* completely empty */ - if (!temp_res) - exit(1); + YAZ_CHECK(temp_res); zs = zebra_start_res(0, default_res, temp_res); - if (!zs) - exit(2); + YAZ_CHECK(zs); zh = zebra_open(zs, 0); + YAZ_CHECK(zh); - zebra_select_database(zh, "Default"); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); /* run this a few times so we can see leaks easier */ for (i = 0; i<10; i++) { /* we should find the name1 from default_res */ val = zebra_get_resource(zh, "name1", 0); - if (!val || strcmp(val, "value1")) - exit(3); + YAZ_CHECK(val && !strcmp(val, "value1")); /* make local override */ res_set(temp_res, "name1", "value2"); @@ -65,16 +64,13 @@ void tst() /* we should find the name1 from temp_res */ val = zebra_get_resource(zh, "name1", 0); - if (!val || strcmp(val, "value2")) - exit(4); + YAZ_CHECK(val && !strcmp(val, "value2")); val = zebra_get_resource(zh, "name4", 0); - if (!val || strcmp(val, "value4")) - exit(4); + YAZ_CHECK(val && !strcmp(val, "value4")); res_clear(temp_res); } - zebra_close(zh); zebra_stop(zs); @@ -82,8 +78,50 @@ void tst() res_close(default_res); } -int main(int argc, char **argv) +static void tst_no_config(void) +{ + static char *xml_buf = "myx"; + ZebraService zs; + ZebraHandle zh; + SYSNO sysno = 0; + + zs = zebra_start_res(0, 0, 0); + YAZ_CHECK(zs); + + zh = zebra_open(zs, 0); + YAZ_CHECK(zh); + + YAZ_CHECK_EQ(zebra_select_database(zh, "Default"), ZEBRA_OK); + + YAZ_CHECK_EQ(zebra_init(zh), ZEBRA_OK); + + zebra_set_resource(zh, "profilePath", "${srcdir:-.}/../../tab"); + + YAZ_CHECK_EQ(zebra_insert_record(zh /* handle */, + "grs.sgml" /* record type */, + &sysno, 0 /* match */, + 0 /* fname */, + xml_buf, strlen(xml_buf), + 0 /* force_update */), + ZEBRA_OK); + + zebra_close(zh); + zebra_stop(zs); +} + +static void tst(int argc, char **argv) { - tst(); - exit(0); + tl_start_log(argc, argv); + tst_res(); + tst_no_config(); } + +TL_MAIN +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +