GnuCash 2.4.99
test-querynew.c
00001 /***************************************************************************
00002  *            test-querynew.c
00003  *
00004  *  Tue Sep 27 19:18:57 2005
00005  *  Copyright  2005  GnuCash team
00006  ****************************************************************************/
00007 /*
00008  *  This program is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; either version 2 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  This program is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *  GNU General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public License
00019  *  along with this program; if not, write to the Free Software
00020  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00021  *  02110-1301, USA.
00022  */
00023 
00024 #include "config.h"
00025 #include <glib.h>
00026 #include <stdio.h>
00027 #include <qof.h>
00028 #include <test-stuff.h>
00029 #include <unittest-support.h>
00030 #include "../cashobjects.h"
00031 
00032 #define TEST_MODULE_NAME        "TestModuleName"
00033 #define TEST_CORE               "TestCoreType"
00034 #define TEST_PARAM              "test-param"
00035 #define BAD_PARAM               "bad-param"
00036 
00037 static int test_sort (gpointer a, gpointer b)
00038 {
00039     return 0;
00040 }
00041 
00042 static int test_core_param (gpointer a)
00043 {
00044     return 0;
00045 }
00046 
00047 static void test_class (void)
00048 {
00049     static QofParam params[] =
00050     {
00051         { TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param, NULL },
00052         { NULL },
00053     };
00054 
00055     gchar *msg1 = "qof_class_get_parameter: assertion `obj_name' failed";
00056     gchar *msg2 = "qof_class_get_parameter: assertion `parameter' failed";
00057     gchar *logdomain = "qof";
00058     guint loglevel = G_LOG_LEVEL_CRITICAL;
00059     TestErrorStruct check1 = { loglevel, logdomain, msg1 };
00060     TestErrorStruct check2 = { loglevel, logdomain, msg2 };
00061     test_add_error (&check1);
00062     test_add_error (&check2);
00063     g_log_set_handler (logdomain, loglevel,
00064                        (GLogFunc)test_list_handler, NULL);
00065 
00066 
00067     qof_class_register (TEST_MODULE_NAME, (QofSortFunc)test_sort, params);
00068 
00069     do_test (qof_class_get_parameter (TEST_MODULE_NAME, TEST_PARAM)
00070              == &params[0], "qof_class_get_parameter");
00071     do_test (qof_class_get_parameter (NULL, NULL) == NULL,
00072              "qof_class_get_parameter (NULL, NULL)");
00073     do_test (qof_class_get_parameter (TEST_MODULE_NAME, NULL) == NULL,
00074              "qof_class_get_parameter (TEST_MODULE_NAME, NULL)");
00075     do_test (qof_class_get_parameter (TEST_MODULE_NAME, BAD_PARAM) == NULL,
00076              "qof_class_get_parameter (TEST_MODULE_NAME, BAD_PARAM)");
00077     do_test (qof_class_get_parameter (NULL, TEST_PARAM) == NULL,
00078              "qof_class_get_parameter (NULL, TEST_PARAM)");
00079 
00080     do_test (qof_class_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM)
00081              == (QofAccessFunc)test_core_param,
00082              "qof_class_get_parameter_getter");
00083 
00084     do_test (safe_strcmp (qof_class_get_parameter_type (TEST_MODULE_NAME,
00085                           TEST_PARAM),
00086                           TEST_CORE) == 0, "qof_class_get_parameter_type");
00087 
00088     /*  do_test (qof_class_get_default_sort (TEST_MODULE_NAME) == test_sort,
00089            "qof_class_get_default_sort");
00090       do_test (qof_class_get_default_sort (NULL) == NULL,
00091            "qof_class_get_default_sort (NULL)");*/
00092     test_clear_error_list ();
00093 }
00094 
00095 static void test_query_core (void)
00096 {
00097 
00098 }
00099 
00100 static void test_querynew (void)
00101 {
00102 }
00103 
00104 int
00105 main (int argc, char **argv)
00106 {
00107     qof_init();
00108     if (cashobjects_register())
00109     {
00110         test_query_core();
00111         test_class();
00112         test_querynew();
00113     }
00114     qof_close();
00115     print_test_results();
00116     return get_rv();
00117 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines