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 #include "qof.h"
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
00037 test_null_guid (void)
00038 {
00039 GUID g;
00040 GUID *gp;
00041
00042 g = guid_new_return ();
00043 gp = guid_malloc ();
00044 guid_new (gp);
00045
00046 do_test (guid_equal (guid_null (), guid_null ()), "null guids equal");
00047 do_test (!guid_equal (&g, gp), "two guids equal");
00048 }
00049
00050 static void
00051 run_test (void)
00052 {
00053 int i;
00054 QofSession *sess;
00055 QofBook *book;
00056 QofEntity *eblk;
00057 QofCollection *col;
00058 QofIdType type;
00059
00060 sess = qof_session_new ();
00061 book = qof_session_get_book (sess);
00062 do_test ((NULL != book), "book not created");
00063
00064 col = qof_book_get_collection (book, "asdf");
00065 type = qof_collection_get_type (col);
00066
00067 #define NENT 500123
00068 eblk = g_new0 (QofEntity, NENT);
00069 for (i = 0; i < NENT; i++)
00070 {
00071 QofEntity *ent = &eblk[i];
00072 guid_new (&ent->guid);
00073 do_test ((NULL == qof_collection_lookup_entity (col, &ent->guid)),
00074 "duplicate guid");
00075 ent->e_type = type;
00076 qof_collection_insert_entity (col, ent);
00077 }
00078
00079
00080 qof_session_destroy (sess);
00081 }
00082
00083 int
00084 main (void)
00085 {
00086 guid_init ();
00087 g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
00088
00089 test_null_guid ();
00090 run_test ();
00091
00092 print_test_results ();
00093 exit (get_rv ());
00094 guid_shutdown ();
00095 return get_rv();
00096 }