fixing leak
[oweals/gnunet.git] / src / monkey / test_monkey_edb.c
1 /*
2      This file is part of GNUnet.
3      (C) 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file monkey/test_monkey_edb.c
22  * @brief testcase for edb_api.c
23  */
24 #include "platform.h"
25 #include "gnunet_common.h"
26 #include "gnunet_monkey_edb.h"
27
28
29 static const char *ref[16] =
30   { "args", "32", "argv", "32", "whole", "42", "whole.member", "42",
31   "whole.member=1", "42", "whole.part", "43", "&part", "43",
32     "whole.part=&part", "43"
33 };
34
35 static int refCount = 0;
36 static int ret = 1;
37
38 int
39 expressionIterator (void *cls, int colNum, char **colValues, char **colNames)
40 {
41   int i;
42   for (i = 0; i < colNum; i++)
43     {
44       if (strcmp (colValues[i], ref[refCount]) != 0)
45         return 1;
46       refCount++;
47     }
48
49   return 0;
50 }
51
52
53 int
54 main (int args, const char *argv[])
55 {
56   struct GNUNET_MONKEY_EDB_Context *cntxt;
57   cntxt = GNUNET_MONKEY_EDB_connect ("test.db");
58   ret =
59     GNUNET_MONKEY_EDB_get_expressions (cntxt,
60                                        "monkey/seaspider/SeaspiderTest.c", 44,
61                                        83, &expressionIterator, NULL);
62   GNUNET_MONKEY_EDB_disconnect (cntxt);
63
64   if (ret == GNUNET_OK)
65     {
66       return 0;
67     }
68   return 1;
69 }