X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ft10.c;h=ee1f87509ff3d631c011d9ac0ffc21796e35ce7b;hb=896b30853daabb6294afe8b0a2f74fa6d6e397d8;hp=cd68776d15b24166c490eaba38abd06cff095d28;hpb=f24cd8a4e4caa9629e6320cfc81a57011c2e9d5e;p=idzebra-moved-to-github.git diff --git a/test/api/t10.c b/test/api/t10.c index cd68776..ee1f875 100644 --- a/test/api/t10.c +++ b/test/api/t10.c @@ -1,5 +1,5 @@ -/* $Id: t10.c,v 1.7 2005-04-28 11:25:24 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: t10.c,v 1.14 2007-01-15 15:10:20 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -15,90 +15,61 @@ 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 + */ -/** t10.c - test zv-rank */ +/* Creates a few result sets */ #include "testlib.h" -#include "rankingrecords.h" - -#define qry(zh,query,hits,string,score) \ - ranking_query(__LINE__,(zh),(query),(hits),(string),(score)) - -struct tst { - char *schema; - char *hit1; - int score1; - char *hit2; - int score2; - char *hit3; - int score3; -}; - - - -struct tst tests[] = { - {"ntc-atn", "first title", 1000, "first title", 1000, "second title",862 }, - {"ntc-ntn", "first title", 1000, "first title", 1000, "second title",862 }, - {"ntc-btn", "first title", 1000, "first title", 1000, "second title",862 }, - {"ntc-apn", "first title", 1000, "first title", 1000, "second title",862 }, - {"ntc-npn", "first title", 1000, "first title", 1000, "second title",862 }, - {"ntc-bpn", "first title", 1000, "first title", 1000, "second title",862 }, - - {"atc-atn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"atc-ntn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"atc-btn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"atc-apn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"atc-npn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"atc-bpn", "first title", 1000, "first title", 1000, "second title", 989 }, - - {"npc-atn", "first title", 1000, "first title", 1000, "second title", 862 }, - {"npc-ntn", "first title", 1000, "first title", 1000, "second title", 862 }, - {"npc-btn", "first title", 1000, "first title", 1000, "second title", 862 }, - {"npc-apn", "first title", 1000, "first title", 1000, "second title", 862 }, - {"npc-npn", "first title", 1000, "first title", 1000, "second title", 862 }, - {"npc-bpn", "first title", 1000, "first title", 1000, "second title", 862 }, - - {"apc-atn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"apc-ntn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"apc-btn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"apc-apn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"apc-npn", "first title", 1000, "first title", 1000, "second title", 989 }, - {"apc-bpn", "first title", 1000, "first title", 1000, "second title", 989 }, - - {0,0,0,0,0,0,0}, -}; - -int main(int argc, char **argv) + +const char *myrec[] ={ + "\n" + " My title\n" + "\n", + 0}; + +static void tst(int argc, char **argv) { - int i; - ZebraService zs = start_up("zebrazv.cfg", argc, argv); - ZebraHandle zh = zebra_open (zs); - - int loglevel = yaz_log_mask_str("zvrank,rank1,t10"); - init_data(zh, recs); - zebra_close(zh); - yaz_log_init_level(loglevel); - for (i = 0; tests[i].schema; i++) - { - zh = zebra_open (zs); - zebra_select_database(zh, "Default"); - zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema); - yaz_log(loglevel,"============%d: %s ===========", i, tests[i].schema); - - ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 the", - 3, tests[i].hit1, tests[i].score1); - ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar", - 3, tests[i].hit2, tests[i].score2); - ranking_query( __LINE__, zh, - "@attr 1=1016 @attr 2=102 @or @or the foo bar", - 3, tests[i].hit3, tests[i].score3); - - zebra_close(zh); - } - - return close_down(0,zs,0); + ZebraService zs = tl_start_up("zebra10.cfg", argc, argv); + ZebraHandle zh = zebra_open(zs, 0); + + YAZ_CHECK(tl_init_data(zh, myrec)); + + zebra_commit(zh); + + // string attributes in search + YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1)); + YAZ_CHECK(tl_query(zh, "@attr 1=title titlex", 0)); + YAZ_CHECK(tl_query(zh, "@attr 1=extra_title my", 1)); + + // numeric attributes with Bib-1 should produce an error + YAZ_CHECK(tl_query_x(zh, + "@attr 1=4 my", 0, 121)); + YAZ_CHECK(tl_query_x(zh, + "@attr 1=7 my", 0, 121)); + // private OID with incorrect use attribute + YAZ_CHECK(tl_query_x(zh, + "@attr 1.2.840.10003.3.1000.1000.1 1=4 my", 0, 114)); + // private OID with OK use attribute + YAZ_CHECK(tl_query(zh, + "@attr 1.2.840.10003.3.1000.1000.1 1=7 my", 1)); + + YAZ_CHECK(tl_query(zh, + "@attr 1.2.840.10003.3.1000.1000.1 1=8 my", 1)); + + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +