It's a good idea to test that the lifecycle of your object is what you expect when writing your unit tests with GTest (and I hope you do). Here is a quick way to do that.
- static void
- my_object_test (void)
- MyObject *obj = my_object_new();
- /* play with obj */
- g_object_add_weak_pointer(G_OBJECT(obj), (gpointer *)&obj);