00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <glib.h>
00023 #include <stdio.h>
00024
00025 #include "qof.h"
00026 #include "qofclass-p.h"
00027 #include "qofquerycore-p.h"
00028
00029 #include "test-stuff.h"
00030
00031 #define TEST_MODULE_NAME "TestModuleName"
00032 #define TEST_MODULE_DESC "Test Object"
00033 #define TEST_CORE "TestCoreType"
00034 #define TEST_PARAM "test-param"
00035 #define BAD_PARAM "bad-param"
00036
00037 static void
00038 obj_foreach (QofCollection *col, QofEntityForeachCB cb, gpointer u_d)
00039 {
00040 int *foo = u_d;
00041
00042 do_test (col != NULL, "foreach: NULL collection");
00043 success ("called foreach callback");
00044
00045 *foo = 1;
00046 }
00047
00048 static const char *
00049 printable (gpointer obj)
00050 {
00051 do_test (obj != NULL, "printable: object is NULL");
00052 success ("called printable callback");
00053 return ((const char *)obj);
00054 }
00055
00056 static QofObject bus_obj = {
00057 interface_version: QOF_OBJECT_VERSION,
00058 e_type: TEST_MODULE_NAME,
00059 type_label: TEST_MODULE_DESC,
00060 create: NULL,
00061 book_begin: NULL,
00062 book_end: NULL,
00063 is_dirty: NULL,
00064 mark_clean: NULL,
00065 foreach: obj_foreach,
00066 printable: printable,
00067 version_cmp: NULL,
00068 };
00069
00070 static int test_sort (gpointer a, gpointer b)
00071 {
00072 return 0;
00073 }
00074
00075 static int test_core_param (gpointer a)
00076 {
00077 return 0;
00078 }
00079
00080 static void test_class (void)
00081 {
00082 static QofParam params[] = {
00083 { TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param, NULL },
00084 { NULL },
00085 };
00086
00087 fprintf (stderr, "\tTesting the qof_query_object interface. \n"
00088 "\tYou may see some \"** CRITICAL **\" messages, which you can safely ignore\n");
00089 do_test (qof_object_register (&bus_obj), "register test object");
00090
00091 qof_class_register (TEST_MODULE_NAME, (QofSortFunc)test_sort, params);
00092
00093 do_test (qof_class_get_parameter (TEST_MODULE_NAME, TEST_PARAM)
00094 == ¶ms[0], "qof_class_get_parameter");
00095 do_test (qof_class_get_parameter (NULL, NULL) == NULL,
00096 "qof_class_get_parameter (NULL, NULL)");
00097 do_test (qof_class_get_parameter (TEST_MODULE_NAME, NULL) == NULL,
00098 "qof_class_get_parameter (TEST_MODULE_NAME, NULL)");
00099 do_test (qof_class_get_parameter (TEST_MODULE_NAME, BAD_PARAM) == NULL,
00100 "qof_class_get_parameter (TEST_MODULE_NAME, BAD_PARAM)");
00101 do_test (qof_class_get_parameter (NULL, TEST_PARAM) == NULL,
00102 "qof_class_get_parameter (NULL, TEST_PARAM)");
00103
00104 do_test (qof_class_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM)
00105 == (QofAccessFunc)test_core_param,
00106 "qof_class_get_parameter_getter");
00107
00108 do_test (safe_strcmp (qof_class_get_parameter_type (TEST_MODULE_NAME,
00109 TEST_PARAM),
00110 TEST_CORE) == 0, "qof_class_get_parameter_type");
00111
00112 do_test (qof_class_get_default_sort (TEST_MODULE_NAME) == (QofSortFunc)test_sort,
00113 "qof_class_get_default_sort");
00114 do_test (qof_class_get_default_sort (NULL) == NULL,
00115 "qof_class_get_default_sort (NULL)");
00116 }
00117
00118 static void test_query_core (void)
00119 {
00120
00121 }
00122
00123 static void test_querynew (void)
00124 {
00125 }
00126
00127 int
00128 main (int argc, char **argv)
00129 {
00130 gnc_engine_get_string_cache ();
00131 guid_init ();
00132 qof_object_initialize ();
00133 qof_book_register ();
00134 qof_query_init ();
00135 test_query_core();
00136 test_class();
00137 test_querynew();
00138 print_test_results();
00139 exit(get_rv());
00140 qof_query_shutdown();
00141 guid_shutdown();
00142 qof_object_shutdown ();
00143 gnc_engine_string_cache_destroy();
00144 return 0;
00145 }