00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <ctype.h>
00026 #include <glib.h>
00027
00028 #include "test-stuff.h"
00029 #include "test-engine-stuff.h"
00030 #include "qofbook.h"
00031 #include "qofid.h"
00032 #include "qofid-p.h"
00033 #include "qofsession.h"
00034 #include "guid.h"
00035
00036 static void test_null_guid(void)
00037 {
00038 GUID g;
00039 GUID *gp;
00040
00041 g = guid_new_return();
00042 gp = guid_malloc();
00043 guid_new(gp);
00044
00045 do_test(guid_equal(guid_null(), guid_null()), "null guids equal");
00046 do_test(!guid_equal(&g, gp), "two guids equal");
00047 }
00048
00049 static void
00050 run_test (void)
00051 {
00052 int i;
00053 QofSession *sess;
00054 QofBook *book;
00055 QofEntity *eblk;
00056 QofCollection *col;
00057 QofIdType type;
00058
00059 sess = qof_session_new();
00060 book = qof_session_get_book (sess);
00061 do_test ((NULL != book), "book not created");
00062
00063 col = qof_book_get_collection (book, "asdf");
00064 type = qof_collection_get_type (col);
00065
00066 #define NENT 500123
00067 eblk = g_new0(QofEntity, NENT);
00068 for (i=0; i<NENT; i++)
00069 {
00070 QofEntity *ent = &eblk[i];
00071 guid_new(&ent->guid);
00072 do_test ((NULL == qof_collection_lookup_entity (col, &ent->guid)),
00073 "duplicate guid");
00074 ent->e_type = type;
00075 qof_collection_insert_entity (col, ent);
00076 }
00077
00078
00079 qof_session_destroy(sess);
00080 }
00081
00082 int
00083 main (int argc, char **argv)
00084 {
00085 guid_init ();
00086 g_log_set_always_fatal( G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING );
00087
00088 test_null_guid();
00089 run_test();
00090
00091 print_test_results();
00092 exit(get_rv());
00093 guid_shutdown();
00094 return 0;
00095 }