|
GnuCash 2.4.99
|
00001 /******************************************************************** 00002 * test_qofinstance.c: GLib g_test test suite for qofinstance. * 00003 * Copyright 2011 John Ralls <jralls@ceridwen.us> * 00004 * * 00005 * This program is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU General Public License as * 00007 * published by the Free Software Foundation; either version 2 of * 00008 * the License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License* 00016 * along with this program; if not, contact: * 00017 * * 00018 * Free Software Foundation Voice: +1-617-542-5942 * 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00020 * Boston, MA 02110-1301, USA gnu@gnu.org * 00021 \********************************************************************/ 00022 #include <config.h> 00023 #include <glib.h> 00024 #include <unittest-support.h> 00025 #include "../qof.h" 00026 #include "../qofbackend-p.h" 00027 00028 static const gchar *suitename = "/qof/qofinstance"; 00029 void test_suite_qofinstance ( void ); 00030 static gchar* error_message; 00031 static gboolean is_called; 00032 00033 typedef struct 00034 { 00035 QofInstance *inst; 00036 } Fixture; 00037 00038 /* use g_free on error_message after this function been called */ 00039 static gboolean 00040 fatal_handler ( const char * log_domain, 00041 GLogLevelFlags log_level, 00042 const gchar *msg, 00043 gpointer user_data) 00044 { 00045 error_message = (gchar *) g_strdup( msg ); 00046 return FALSE; 00047 } 00048 00049 static void 00050 setup( Fixture *fixture, gconstpointer pData ) 00051 { 00052 fixture->inst = g_object_new(QOF_TYPE_INSTANCE, NULL); 00053 } 00054 00055 static void 00056 teardown( Fixture *fixture, gconstpointer pData ) 00057 { 00058 g_object_unref(fixture->inst); 00059 } 00060 00061 static void 00062 test_instance_set_get_book( Fixture *fixture, gconstpointer pData ) 00063 { 00064 QofBook *book; 00065 00066 /* set up */ 00067 book = qof_book_new(); 00068 00069 g_assert( QOF_IS_INSTANCE( fixture->inst ) ); 00070 00071 g_test_message( "Setting and getting book" ); 00072 qof_instance_set_book( fixture->inst, book ); 00073 g_assert( book == qof_instance_get_book( fixture->inst ) ); 00074 00075 g_test_message( "Getting book when instance is null" ); 00076 g_assert( qof_instance_get_book( NULL ) == NULL ); 00077 00078 /* Clean up */ 00079 qof_book_destroy( book ); 00080 } 00081 00082 static void 00083 test_instance_set_get_guid( Fixture *fixture, gconstpointer pData ) 00084 { 00085 GncGUID *gncGuid; 00086 00087 /* on null instance deprecated getter returns empty guid 00088 * while instance_get_guid returns null 00089 */ 00090 g_assert( !qof_instance_get_guid( NULL ) ); 00091 g_assert( qof_entity_get_guid( NULL ) == guid_null() ); 00092 00093 /* set up */ 00094 gncGuid = guid_malloc(); 00095 guid_new( gncGuid ); 00096 g_assert( QOF_IS_INSTANCE( fixture->inst ) ); 00097 g_assert( gncGuid ); 00098 00099 /* guid already exists after instance init */ 00100 g_test_message( "Setting new guid" ); 00101 g_assert( qof_instance_get_guid( fixture->inst ) ); 00102 g_assert( !guid_equal( gncGuid, qof_instance_get_guid( fixture->inst ) ) ); 00103 qof_instance_set_guid( fixture->inst, gncGuid ); 00104 g_assert( guid_equal( gncGuid, qof_instance_get_guid( fixture->inst ) ) ); 00105 g_assert( guid_equal( gncGuid, qof_entity_get_guid( fixture->inst ) ) ); 00106 00107 /* Clean up */ 00108 guid_free( gncGuid ); 00109 } 00110 00111 static void 00112 test_instance_new_destroy( void ) 00113 { 00114 /* qofinstance var */ 00115 QofInstance *inst; 00116 QofInstanceClass *klass; 00117 /* test var */ 00118 Timespec *timespec_priv; 00119 gchar *msg1 = "qof_instance_get_collection: assertion `QOF_IS_INSTANCE(ptr)' failed"; 00120 gchar *msg2 = "qof_instance_get_editlevel: assertion `QOF_IS_INSTANCE(ptr)' failed"; 00121 gchar *msg3 = "qof_instance_get_destroying: assertion `QOF_IS_INSTANCE(ptr)' failed"; 00122 gchar *msg4 = "qof_instance_get_dirty_flag: assertion `QOF_IS_INSTANCE(ptr)' failed"; 00123 gchar *log_domain = "qof"; 00124 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL, hdlr; 00125 TestErrorStruct check = { loglevel, log_domain, msg1 }; 00126 00127 g_test_message( "Testing qofinstance object initialization" ); 00128 inst = g_object_new(QOF_TYPE_INSTANCE, NULL); 00129 g_assert( QOF_IS_INSTANCE( inst ) ); 00130 /* test class fields */ 00131 klass = QOF_INSTANCE_GET_CLASS( inst ); 00132 g_assert( QOF_IS_INSTANCE_CLASS( klass ) ); 00133 g_assert( klass->get_display_name == NULL ); 00134 g_assert( klass->refers_to_object == NULL ); 00135 g_assert( klass->get_typed_referring_object_list == NULL ); 00136 /* testing initial values */ 00137 g_assert( qof_instance_get_guid( inst ) ); 00138 g_assert( !qof_instance_get_collection( inst ) ); 00139 g_assert( qof_instance_get_book( inst ) == NULL ); 00140 g_assert( inst->kvp_data ); 00141 g_object_get( inst, "last-update", ×pec_priv, NULL); 00142 g_assert_cmpint( timespec_priv->tv_sec, == , 0 ); 00143 g_assert_cmpint( timespec_priv->tv_nsec, == , -1 ); 00144 g_assert_cmpint( qof_instance_get_editlevel( inst ), == , 0 ); 00145 g_assert( !qof_instance_get_destroying( inst ) ); 00146 g_assert( !qof_instance_get_dirty_flag( inst ) ); 00147 g_assert( qof_instance_get_infant( inst ) ); 00148 g_assert_cmpint( qof_instance_get_version( inst ), == , 0 ); 00149 g_assert_cmpint( qof_instance_get_version_check( inst ), == , 0 ); 00150 g_assert_cmpint( qof_instance_get_idata( inst ), == , 0 ); 00151 00152 g_test_message( "Testing object destruction" ); 00153 g_object_unref( inst ); 00154 /* test fields were deinitialized */ 00155 g_assert( inst ); 00156 g_assert( !QOF_IS_INSTANCE( inst ) ); 00157 /* set fatal handler */ 00158 g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )fatal_handler, NULL ); 00159 hdlr = g_log_set_handler (log_domain, loglevel, 00160 (GLogFunc)test_checked_handler, &check); 00161 g_assert( qof_instance_get_collection( inst ) == NULL ); 00162 g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL ); 00163 g_free( error_message ); 00164 00165 check.msg = msg2; 00166 g_assert_cmpint( qof_instance_get_editlevel( inst ), == , 0 ); 00167 g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL ); 00168 g_free( error_message ); 00169 00170 check.msg = msg3; 00171 g_assert( !qof_instance_get_destroying( inst ) ); 00172 g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL ); 00173 g_free( error_message ); 00174 00175 check.msg = msg4; 00176 g_assert( !qof_instance_get_dirty_flag( inst ) ); 00177 g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL ); 00178 g_free( error_message ); 00179 g_log_remove_handler (log_domain, hdlr); 00180 } 00181 00182 static void 00183 test_instance_init_data( void ) 00184 { 00185 QofInstance *inst; 00186 QofIdType test_type = "test type"; 00187 QofBook *book; 00188 QofCollection *col; 00189 const GncGUID *gncguid; 00190 char guid_id_before[GUID_ENCODING_LENGTH + 1]; 00191 char guid_id_after[GUID_ENCODING_LENGTH + 1]; 00192 00193 /* set up */ 00194 inst = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00195 g_assert( QOF_IS_INSTANCE( inst ) ); 00196 book = qof_book_new(); 00197 g_assert( QOF_IS_BOOK( book ) ); 00198 /* set fatal handler */ 00199 g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )fatal_handler, NULL ); 00200 00201 g_test_message( "Running test with correct initial data" ); 00202 gncguid = qof_instance_get_guid( inst ); 00203 g_assert( gncguid ); 00204 guid_to_string_buff( gncguid, guid_id_before ); 00205 g_assert( qof_instance_get_book( inst ) == NULL ); 00206 g_assert( qof_instance_get_collection( inst ) == NULL ); 00207 /* run init */ 00208 qof_instance_init_data( inst, test_type, book ); 00209 00210 g_assert( qof_instance_get_book( inst ) == book ); 00211 guid_to_string_buff( gncguid, guid_id_after ); 00212 g_assert_cmpstr( guid_id_before, != , guid_id_after ); 00213 g_assert( qof_instance_get_collection( inst ) != NULL ); 00214 col = qof_book_get_collection( book, test_type ); 00215 g_assert( col ); 00216 g_assert( col == qof_instance_get_collection( inst ) ); 00217 g_assert_cmpstr( inst->e_type, == , test_type ); 00218 g_assert( qof_collection_lookup_entity( qof_instance_get_collection( inst ), gncguid ) == inst ); 00219 00220 /* clean up */ 00221 g_object_unref( inst ); 00222 qof_book_destroy( book ); 00223 } 00224 00225 static void 00226 test_instance_get_set_slots( Fixture *fixture, gconstpointer pData ) 00227 { 00228 KvpFrame *kvp_frame, *kvp_frame2; 00229 00230 /* set up */ 00231 g_assert( fixture->inst ); 00232 kvp_frame = qof_instance_get_slots( fixture->inst ); 00233 g_assert( kvp_frame ); 00234 00235 g_test_message( "Test when kvp frame is the same" ); 00236 qof_instance_set_slots( fixture->inst, kvp_frame ); 00237 g_assert( kvp_frame == qof_instance_get_slots( fixture->inst ) ); 00238 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00239 00240 g_test_message( "Test when kvp frame is not the same" ); 00241 kvp_frame2 = kvp_frame_new(); 00242 g_assert( kvp_frame != kvp_frame2 ); 00243 qof_instance_set_slots( fixture->inst, kvp_frame2 ); 00244 g_assert( kvp_frame2 == qof_instance_get_slots( fixture->inst ) ); 00245 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00246 00247 g_test_message( "Test when kvp frame is null" ); 00248 qof_instance_set_slots( fixture->inst, NULL ); 00249 g_assert( NULL == qof_instance_get_slots( fixture->inst ) ); 00250 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00251 00252 } 00253 00254 static void 00255 test_instance_version_cmp( void ) 00256 { 00257 QofInstance *left, *right; 00258 int result; 00259 Timespec timespec_left, timespec_right; 00260 00261 /* set up*/ 00262 left = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00263 right = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00264 00265 g_test_message( "Test both null" ); 00266 result = qof_instance_version_cmp( NULL, NULL ); 00267 g_assert_cmpint( result, == , 0 ); 00268 00269 g_test_message( "Test left null" ); 00270 result = qof_instance_version_cmp( NULL, right ); 00271 g_assert_cmpint( result, == , -1 ); 00272 00273 g_test_message( "Test right null" ); 00274 result = qof_instance_version_cmp( left, NULL ); 00275 g_assert_cmpint( result, == , 1 ); 00276 00277 g_test_message( "Test left tv_sec lesser than right" ); 00278 timespec_left.tv_sec = 0; 00279 timespec_right.tv_sec = 1; 00280 qof_instance_set_last_update( left, timespec_left ); 00281 qof_instance_set_last_update( right, timespec_right ); 00282 result = qof_instance_version_cmp( left, right ); 00283 g_assert_cmpint( result, == , -1 ); 00284 00285 g_test_message( "Test right tv_sec lesser than left" ); 00286 timespec_left.tv_sec = 1; 00287 timespec_right.tv_sec = 0; 00288 qof_instance_set_last_update( left, timespec_left ); 00289 qof_instance_set_last_update( right, timespec_right ); 00290 result = qof_instance_version_cmp( left, right ); 00291 g_assert_cmpint( result, == , 1 ); 00292 00293 g_test_message( "Test left tv_nsec lesser than right" ); 00294 timespec_left.tv_sec = 1; 00295 timespec_left.tv_nsec = 0; 00296 timespec_right.tv_sec = 1; 00297 timespec_right.tv_nsec = 1; 00298 qof_instance_set_last_update( left, timespec_left ); 00299 qof_instance_set_last_update( right, timespec_right ); 00300 result = qof_instance_version_cmp( left, right ); 00301 g_assert_cmpint( result, == , -1 ); 00302 00303 g_test_message( "Test right tv_sec lesser than left" ); 00304 timespec_left.tv_sec = 1; 00305 timespec_left.tv_nsec = 1; 00306 timespec_right.tv_sec = 1; 00307 timespec_right.tv_nsec = 0; 00308 qof_instance_set_last_update( left, timespec_left ); 00309 qof_instance_set_last_update( right, timespec_right ); 00310 result = qof_instance_version_cmp( left, right ); 00311 g_assert_cmpint( result, == , 1 ); 00312 00313 g_test_message( "Test both equal" ); 00314 timespec_left.tv_sec = 1; 00315 timespec_left.tv_nsec = 1; 00316 timespec_right.tv_sec = 1; 00317 timespec_right.tv_nsec = 1; 00318 qof_instance_set_last_update( left, timespec_left ); 00319 qof_instance_set_last_update( right, timespec_right ); 00320 result = qof_instance_version_cmp( left, right ); 00321 g_assert_cmpint( result, == , 0 ); 00322 00323 /* clear */ 00324 g_object_unref( left ); 00325 g_object_unref( right ); 00326 } 00327 00328 static void 00329 test_instance_get_set_dirty( Fixture *fixture, gconstpointer pData ) 00330 { 00331 QofIdType type = "test type"; 00332 QofCollection *col; 00333 00334 /* setup */ 00335 col = qof_collection_new ( type ); 00336 qof_instance_set_collection( fixture->inst, col ); 00337 g_assert( qof_instance_get_collection( fixture->inst ) ); 00338 00339 g_test_message( "Test get_dirty on empty instance returns false" ); 00340 g_assert( qof_instance_get_dirty( NULL ) == FALSE ); 00341 00342 g_test_message( "Test dirty in normal mode" ); 00343 g_assert( !qof_get_alt_dirty_mode() ); 00344 g_assert( !qof_instance_get_dirty_flag( fixture->inst ) ); 00345 g_assert( !qof_collection_is_dirty( col ) ); 00346 g_assert( !qof_instance_get_dirty( fixture->inst ) ); 00347 qof_instance_set_dirty( fixture->inst ); 00348 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00349 g_assert( qof_collection_is_dirty( col ) ); 00350 g_assert( qof_instance_get_dirty( fixture->inst ) ); 00351 00352 00353 g_test_message( "Test dirty in alternate mode" ); 00354 qof_set_alt_dirty_mode ( TRUE ); 00355 /* restore */ 00356 qof_collection_mark_clean( col ); 00357 qof_instance_set_dirty_flag( fixture->inst, FALSE ); 00358 00359 g_assert( qof_get_alt_dirty_mode() ); 00360 g_assert( !qof_instance_get_dirty_flag( fixture->inst ) ); 00361 g_assert( !qof_collection_is_dirty( col ) ); 00362 g_assert( !qof_instance_get_dirty( fixture->inst ) ); 00363 qof_instance_set_dirty( fixture->inst ); 00364 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00365 g_assert( !qof_collection_is_dirty( col ) ); 00366 g_assert( qof_instance_get_dirty( fixture->inst ) ); 00367 00368 /* clean up */ 00369 qof_instance_set_collection( fixture->inst, NULL ); 00370 qof_collection_destroy( col ); 00371 } 00372 00373 /* mock display name function */ 00374 static gchar* 00375 mock_get_display_name(const QofInstance* inst) 00376 { 00377 gchar *display_name; 00378 00379 g_assert( inst ); 00380 g_assert( QOF_INSTANCE_GET_CLASS( inst )->get_display_name == mock_get_display_name ); 00381 is_called = TRUE; 00382 display_name = g_strdup_printf("Mock display name %p", inst ); 00383 return display_name; 00384 } 00385 00386 static void 00387 test_instance_display_name( Fixture *fixture, gconstpointer pData ) 00388 { 00389 QofIdType type = "test type"; 00390 QofCollection *col; 00391 gchar *display_name, *default_display_name, *mock_display_name; 00392 00393 /* setup */ 00394 g_assert( fixture->inst ); 00395 is_called = FALSE; 00396 col = qof_collection_new ( type ); 00397 g_assert( col ); 00398 qof_instance_set_collection( fixture->inst, col ); 00399 g_assert( qof_instance_get_collection( fixture->inst ) ); 00400 default_display_name = g_strdup_printf( "Object %s %p", type, fixture->inst ); 00401 mock_display_name = g_strdup_printf( "Mock display name %p", fixture->inst ); 00402 00403 g_test_message( "Test instance when display name not set" ); 00404 g_assert( QOF_INSTANCE_GET_CLASS( fixture->inst )->get_display_name == NULL ); 00405 display_name = qof_instance_get_display_name( fixture->inst ); 00406 g_assert( !is_called ); 00407 g_assert_cmpstr( display_name, == , default_display_name ); 00408 g_free( display_name ); 00409 00410 g_test_message( "Test instance when display name is set" ); 00411 QOF_INSTANCE_GET_CLASS( fixture->inst )->get_display_name = mock_get_display_name; 00412 display_name = qof_instance_get_display_name( fixture->inst ); 00413 g_assert( is_called ); 00414 g_assert_cmpstr( display_name, == , mock_display_name ); 00415 g_free( display_name ); 00416 00417 /* clean up */ 00418 g_free( default_display_name ); 00419 g_free( mock_display_name ); 00420 qof_instance_set_collection( fixture->inst, NULL ); 00421 qof_collection_destroy( col ); 00422 } 00423 00424 static void 00425 mock_backend_begin( QofBackend *be, QofInstance *inst ) 00426 { 00427 g_assert( be ); 00428 g_assert( inst ); 00429 g_assert( be->begin == mock_backend_begin ); 00430 g_assert_cmpstr( inst->e_type, == , "test type" ); 00431 is_called = TRUE; 00432 } 00433 00434 static void 00435 test_instance_begin_edit( Fixture *fixture, gconstpointer pData ) 00436 { 00437 QofBackend *be; 00438 QofBook *book; 00439 gboolean result; 00440 00441 /* setup */ 00442 be = g_new0( QofBackend, 1 ); 00443 g_assert( be ); 00444 qof_backend_init( be ); 00445 book = qof_book_new(); 00446 g_assert( book ); 00447 g_assert( QOF_IS_BOOK( book ) ); 00448 qof_book_set_backend( book, be ); 00449 g_assert( fixture->inst ); 00450 fixture->inst->e_type = "test type"; 00451 g_assert( qof_instance_get_dirty_flag( fixture->inst ) == FALSE ); 00452 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 0 ); 00453 00454 g_test_message( "Test when instance is null" ); 00455 result = qof_begin_edit( NULL ); 00456 g_assert( result == FALSE ); 00457 00458 g_test_message( "Test when instance's editlevel is >= 1" ); 00459 qof_instance_increase_editlevel( fixture->inst ); 00460 result = qof_begin_edit( fixture->inst ); 00461 g_assert( result == FALSE ); 00462 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 2 ); 00463 00464 g_test_message( "Test when instance's editlevel is <= 0 and backend not set" ); 00465 qof_instance_reset_editlevel( fixture->inst ); 00466 result = qof_begin_edit( fixture->inst ); 00467 g_assert( result == TRUE ); 00468 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 1 ); 00469 g_assert( qof_instance_get_dirty_flag( fixture->inst ) == TRUE ); 00470 00471 g_test_message( "Test when instance's editlevel is <= 0 and backend is set" ); 00472 result = FALSE; 00473 is_called = FALSE; 00474 qof_instance_reset_editlevel( fixture->inst ); 00475 qof_instance_set_dirty_flag( fixture->inst, FALSE ); 00476 qof_instance_set_book( fixture->inst, book ); 00477 be->begin = mock_backend_begin; 00478 result = qof_begin_edit( fixture->inst ); 00479 g_assert( result == TRUE ); 00480 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 1 ); 00481 g_assert( qof_instance_get_dirty_flag( fixture->inst ) == FALSE ); 00482 g_assert( is_called ); 00483 00484 /* clean up */ 00485 qof_book_set_backend( book, NULL ); 00486 qof_book_destroy( book ); 00487 qof_backend_destroy( be ); 00488 g_free( be ); 00489 } 00490 00491 static void 00492 test_instance_commit_edit( Fixture *fixture, gconstpointer pData ) 00493 { 00494 gboolean result; 00495 gchar *msg = "[qof_commit_edit()] unbalanced call - resetting (was -2)"; 00496 gchar *log_domain = "qof.engine"; 00497 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL, hdlr; 00498 TestErrorStruct check = { loglevel, log_domain, msg }; 00499 00500 g_test_message( "Test when instance set to null" ); 00501 result = qof_commit_edit( NULL ); 00502 g_assert( !result ); 00503 00504 g_test_message( "Test when instance's editlevel >= 2" ); 00505 qof_instance_increase_editlevel( fixture->inst ); 00506 qof_instance_increase_editlevel( fixture->inst ); 00507 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 2 ); 00508 result = qof_commit_edit( fixture->inst ); 00509 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 1 ); 00510 g_assert( !result ); 00511 00512 g_test_message( "Test when instance's editlevel = 1" ); 00513 result = qof_commit_edit( fixture->inst ); 00514 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 0 ); 00515 g_assert( result ); 00516 00517 g_test_message( "Test when instance's editlevel < 0" ); 00518 g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )fatal_handler, NULL ); 00519 hdlr = g_log_set_handler (log_domain, loglevel, 00520 (GLogFunc)test_checked_handler, &check); 00521 qof_instance_decrease_editlevel( fixture->inst ); 00522 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , -1 ); 00523 result = qof_commit_edit( fixture->inst ); 00524 g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 0 ); 00525 g_assert_cmpstr( error_message, == , "[qof_commit_edit()] unbalanced call - resetting (was -2)" ); 00526 g_free( error_message ); 00527 g_log_remove_handler (log_domain, hdlr); 00528 } 00529 00530 /* backend commit test start */ 00531 00532 static struct 00533 { 00534 gpointer inst; 00535 gpointer be; 00536 00537 gboolean commit_called; 00538 gboolean commit_with_err_called; 00539 gboolean on_error_called; 00540 gboolean on_free_called; 00541 gboolean on_done_called; 00542 QofBackendError err; 00543 } commit_test_part2; 00544 00545 static void 00546 mock_backend_commit( QofBackend *be, QofInstance *inst ) 00547 { 00548 g_assert( inst ); 00549 g_assert( be ); 00550 g_assert( QOF_IS_INSTANCE( inst ) ); 00551 g_assert( commit_test_part2.inst == inst ); 00552 g_assert( commit_test_part2.be == be ); 00553 commit_test_part2.commit_called = TRUE; 00554 } 00555 00556 static void 00557 mock_backend_commit_with_error( QofBackend *be, QofInstance *inst ) 00558 { 00559 g_assert( inst ); 00560 g_assert( be ); 00561 g_assert( QOF_IS_INSTANCE( inst ) ); 00562 g_assert( commit_test_part2.inst == inst ); 00563 g_assert( commit_test_part2.be == be ); 00564 qof_backend_set_error( be, ERR_BACKEND_NO_HANDLER ); 00565 commit_test_part2.err = ERR_BACKEND_NO_HANDLER; 00566 commit_test_part2.commit_with_err_called = TRUE; 00567 } 00568 00569 00570 static void 00571 mock_on_error( QofInstance *inst, QofBackendError be_error ) 00572 { 00573 g_assert( inst ); 00574 g_assert( QOF_IS_INSTANCE( inst ) ); 00575 g_assert( commit_test_part2.err == be_error ); 00576 commit_test_part2.on_error_called = TRUE; 00577 } 00578 00579 static void 00580 mock_on_done( QofInstance *inst ) 00581 { 00582 g_assert( inst ); 00583 g_assert( QOF_IS_INSTANCE( inst ) ); 00584 g_assert( commit_test_part2.inst == inst ); 00585 commit_test_part2.on_done_called = TRUE; 00586 } 00587 00588 static void 00589 mock_on_free( QofInstance *inst ) 00590 { 00591 g_assert( inst ); 00592 g_assert( QOF_IS_INSTANCE( inst ) ); 00593 g_assert( commit_test_part2.inst == inst ); 00594 commit_test_part2.on_free_called = TRUE; 00595 } 00596 00597 static void 00598 test_instance_commit_edit_part2( Fixture *fixture, gconstpointer pData ) 00599 { 00600 QofBackend *be; 00601 QofBook *book; 00602 gboolean result; 00603 00604 /* setup */ 00605 be = g_new0( QofBackend, 1 ); 00606 g_assert( be ); 00607 qof_backend_init( be ); 00608 book = qof_book_new(); 00609 g_assert( book ); 00610 g_assert( QOF_IS_BOOK( book ) ); 00611 qof_book_set_backend( book, be ); 00612 00613 /* init */ 00614 result = FALSE; 00615 commit_test_part2.commit_called = FALSE; 00616 commit_test_part2.commit_with_err_called = FALSE; 00617 commit_test_part2.on_error_called = FALSE; 00618 commit_test_part2.on_free_called = FALSE; 00619 commit_test_part2.on_done_called = FALSE; 00620 commit_test_part2.inst = fixture->inst; 00621 commit_test_part2.be = be; 00622 qof_instance_set_dirty_flag( fixture->inst, TRUE ); 00623 00624 g_test_message( "Test when instance's backend not set, callbacks not set" ); 00625 g_assert( qof_instance_get_infant( fixture->inst ) ); 00626 g_assert( !qof_instance_get_destroying( fixture->inst ) ); 00627 result = qof_commit_edit_part2( fixture->inst, NULL, NULL, NULL ); 00628 g_assert( result ); 00629 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00630 g_assert( !qof_instance_get_infant( fixture->inst ) ); 00631 g_assert( !commit_test_part2.commit_called ); 00632 g_assert( !commit_test_part2.commit_with_err_called ); 00633 g_assert( !commit_test_part2.on_error_called ); 00634 g_assert( !commit_test_part2.on_free_called ); 00635 g_assert( !commit_test_part2.on_done_called ); 00636 00637 g_test_message( "Test when instance's backend not set, do_free is true" ); 00638 qof_instance_set_destroying( fixture->inst, TRUE ); 00639 result = qof_commit_edit_part2( fixture->inst, mock_on_error, mock_on_done, mock_on_free ); 00640 g_assert( result ); 00641 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00642 g_assert( !commit_test_part2.commit_called ); 00643 g_assert( !commit_test_part2.commit_with_err_called ); 00644 g_assert( !commit_test_part2.on_error_called ); 00645 g_assert( commit_test_part2.on_free_called ); 00646 g_assert( !commit_test_part2.on_done_called ); 00647 00648 g_test_message( "Test when instance's backend not set, do_free is false" ); 00649 qof_instance_set_destroying( fixture->inst, FALSE ); 00650 commit_test_part2.on_free_called = FALSE; 00651 result = qof_commit_edit_part2( fixture->inst, mock_on_error, mock_on_done, mock_on_free ); 00652 g_assert( result ); 00653 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00654 g_assert( !commit_test_part2.commit_called ); 00655 g_assert( !commit_test_part2.commit_with_err_called ); 00656 g_assert( !commit_test_part2.on_error_called ); 00657 g_assert( !commit_test_part2.on_free_called ); 00658 g_assert( commit_test_part2.on_done_called ); 00659 00660 g_test_message( "Test when instance's backend is set, all cb set, no error produced" ); 00661 qof_instance_set_book( fixture->inst, book ); 00662 qof_instance_set_destroying( fixture->inst, FALSE ); 00663 commit_test_part2.on_done_called = FALSE; 00664 be->commit = mock_backend_commit; 00665 result = qof_commit_edit_part2( fixture->inst, mock_on_error, mock_on_done, mock_on_free ); 00666 g_assert( result ); 00667 g_assert( !qof_instance_get_dirty_flag( fixture->inst ) ); 00668 g_assert( commit_test_part2.commit_called ); 00669 g_assert( !commit_test_part2.commit_with_err_called ); 00670 g_assert( !commit_test_part2.on_error_called ); 00671 g_assert( !commit_test_part2.on_free_called ); 00672 g_assert( commit_test_part2.on_done_called ); 00673 00674 g_test_message( "Test when instance's backend is set, all cb set, error produced" ); 00675 commit_test_part2.commit_called = FALSE; 00676 commit_test_part2.on_done_called = FALSE; 00677 be->commit = mock_backend_commit_with_error; 00678 qof_instance_set_dirty_flag( fixture->inst, TRUE ); 00679 qof_instance_set_destroying( fixture->inst, TRUE ); 00680 result = qof_commit_edit_part2( fixture->inst, mock_on_error, mock_on_done, mock_on_free ); 00681 g_assert( !result ); 00682 g_assert( qof_instance_get_dirty_flag( fixture->inst ) ); 00683 g_assert( !qof_instance_get_destroying( fixture->inst ) ); 00684 g_assert( !commit_test_part2.commit_called ); 00685 g_assert( commit_test_part2.commit_with_err_called ); 00686 g_assert( commit_test_part2.on_error_called ); 00687 g_assert( !commit_test_part2.on_free_called ); 00688 g_assert( !commit_test_part2.on_done_called ); 00689 00690 /* clean up */ 00691 qof_book_set_backend( book, NULL ); 00692 qof_book_destroy( book ); 00693 qof_backend_destroy( be ); 00694 g_free( be ); 00695 } 00696 00697 /* backend commit test end */ 00698 00699 /* object reference tests */ 00700 00701 static struct 00702 { 00703 gpointer inst; 00704 gpointer ref; 00705 00706 gboolean refers_to_object_called; 00707 } refers_test_struct; 00708 00709 static gboolean 00710 mock_refers_to_object( const QofInstance* inst, const QofInstance* ref ) 00711 { 00712 g_assert( inst ); 00713 g_assert( ref ); 00714 g_assert( refers_test_struct.inst == inst ); 00715 g_assert( refers_test_struct.ref == ref ); 00716 refers_test_struct.refers_to_object_called = TRUE; 00717 return TRUE; 00718 } 00719 00720 static void 00721 test_instance_refers_to_object( Fixture *fixture, gconstpointer pData ) 00722 { 00723 QofInstance * ref; 00724 00725 ref = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00726 g_assert( fixture->inst ); 00727 g_assert( ref ); 00728 g_assert( QOF_INSTANCE_GET_CLASS( fixture->inst )->refers_to_object == NULL ); 00729 refers_test_struct.refers_to_object_called = FALSE; 00730 refers_test_struct.inst = fixture->inst; 00731 refers_test_struct.ref = ref; 00732 00733 g_test_message( "Test when refers to object not set" ); 00734 g_assert( !qof_instance_refers_to_object( fixture->inst, ref ) ); 00735 g_assert( !refers_test_struct.refers_to_object_called ); 00736 00737 g_test_message( "Test when refers to object set" ); 00738 QOF_INSTANCE_GET_CLASS( fixture->inst )->refers_to_object = mock_refers_to_object; 00739 g_assert( qof_instance_refers_to_object( fixture->inst, ref ) ); 00740 g_assert( refers_test_struct.refers_to_object_called ); 00741 00742 g_object_unref( ref ); 00743 } 00744 00745 static struct 00746 { 00747 GList *list; 00748 gpointer ref; 00749 guint call_count; 00750 } refers_test_struct_from_col; 00751 00752 static gboolean 00753 mock_refers_to_object_from_col( const QofInstance* inst, const QofInstance* ref ) 00754 { 00755 g_assert( inst ); 00756 g_assert( ref ); 00757 g_assert( g_list_find( refers_test_struct_from_col.list, inst ) ); 00758 g_assert( refers_test_struct_from_col.ref == ref ); 00759 refers_test_struct_from_col.call_count++; 00760 refers_test_struct.refers_to_object_called = TRUE; 00761 return TRUE; 00762 } 00763 00764 static void 00765 test_instance_get_referring_object_list_from_collection( void ) 00766 { 00767 QofIdType type = "test type"; 00768 QofBook *book; 00769 GList *inst_list = NULL; 00770 GList *result = NULL; 00771 QofCollection *coll; 00772 QofInstance *ref; 00773 /* randomly init number of entities >=0 and < 10 */ 00774 gint32 list_length = g_test_rand_int_range( 0, 10 ); 00775 int i; 00776 00777 /* setup book and ref instance */ 00778 book = qof_book_new(); 00779 g_assert( book ); 00780 g_assert( QOF_IS_BOOK( book ) ); 00781 ref = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00782 g_assert( ref ); 00783 g_assert( QOF_IS_INSTANCE( ref ) ); 00784 QOF_INSTANCE_GET_CLASS( ref )->refers_to_object = NULL; 00785 refers_test_struct_from_col.call_count = 0; 00786 /* init list of entities of one type, 00787 * put them into book collection and 00788 * save in the list 00789 */ 00790 for (i = 0; i < list_length; i++ ) 00791 { 00792 QofInstance *inst = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00793 g_assert( inst ); 00794 qof_instance_init_data( inst, type, book ); 00795 inst_list = g_list_append ( inst_list, inst ); 00796 g_assert_cmpint( g_list_length( inst_list ), == , (i + 1) ); 00797 } 00798 g_assert_cmpint( list_length, == , g_list_length( inst_list ) ); 00799 00800 g_test_message( "Test when refers to object not set" ); 00801 coll = qof_book_get_collection( book, type ); 00802 g_assert( coll ); 00803 result = qof_instance_get_referring_object_list_from_collection( coll, ref ); 00804 g_assert( !result ); 00805 g_assert_cmpint( refers_test_struct_from_col.call_count, == , 0 ); 00806 00807 g_test_message( "Test when refers to object is set" ); 00808 QOF_INSTANCE_GET_CLASS( ref )->refers_to_object = mock_refers_to_object_from_col; 00809 refers_test_struct_from_col.list = inst_list; 00810 refers_test_struct_from_col.ref = ref; 00811 result = qof_instance_get_referring_object_list_from_collection( coll, ref ); 00812 if ( list_length == 0 ) 00813 g_assert( !result ); 00814 else 00815 g_assert( result ); 00816 g_assert_cmpint( g_list_length( inst_list ), == , g_list_length( result ) ); 00817 g_assert_cmpint( g_list_length( inst_list ), == , refers_test_struct_from_col.call_count ); 00818 00819 /* clean up list and destroy book */ 00820 g_list_foreach( inst_list, (GFunc) g_object_unref, NULL ); 00821 g_list_free( inst_list ); 00822 g_list_free( result ); 00823 qof_book_destroy( book ); 00824 g_object_unref( ref ); 00825 } 00826 00827 static struct 00828 { 00829 gpointer inst; 00830 gpointer ref; 00831 00832 gboolean get_typed_referring_object_list_called; 00833 } get_typed_referring_object_list_struct; 00834 00835 static GList* 00836 mock_get_typed_referring_object_list( const QofInstance* inst, const QofInstance* ref ) 00837 { 00838 GList* result = NULL; 00839 00840 g_assert( inst ); 00841 g_assert( ref ); 00842 g_assert( get_typed_referring_object_list_struct.inst == inst ); 00843 g_assert( get_typed_referring_object_list_struct.ref == ref ); 00844 get_typed_referring_object_list_struct.get_typed_referring_object_list_called = TRUE; 00845 return g_list_append( result, (gpointer) inst ); 00846 } 00847 00848 static void 00849 test_instance_get_typed_referring_object_list( void ) 00850 { 00851 QofInstance *inst; 00852 QofInstance *ref; 00853 QofBook *book; 00854 GList* result = NULL; 00855 00856 /* setup */ 00857 inst = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00858 ref = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00859 book = qof_book_new(); 00860 g_assert( inst ); 00861 g_assert( ref ); 00862 g_assert( book ); 00863 QOF_INSTANCE_GET_CLASS( inst )->refers_to_object = NULL; 00864 QOF_INSTANCE_GET_CLASS( inst )->get_typed_referring_object_list = NULL; 00865 qof_instance_init_data( inst, "test type", book ); 00866 get_typed_referring_object_list_struct.get_typed_referring_object_list_called = FALSE; 00867 00868 /* 00869 * cases when refers to object is set are not tested in current function 00870 * as they are checked in the previous tests 00871 */ 00872 g_test_message( "Test when get typed referring object list is not set" ); 00873 result = qof_instance_get_typed_referring_object_list( inst, ref ); 00874 g_assert( !result ); 00875 g_assert( !get_typed_referring_object_list_struct.get_typed_referring_object_list_called ); 00876 g_list_free( result ); 00877 00878 g_test_message( "Test when get typed referring object list is set" ); 00879 QOF_INSTANCE_GET_CLASS( inst )->get_typed_referring_object_list = mock_get_typed_referring_object_list; 00880 get_typed_referring_object_list_struct.inst = inst; 00881 get_typed_referring_object_list_struct.ref = ref; 00882 result = qof_instance_get_typed_referring_object_list( inst, ref ); 00883 g_assert( result ); 00884 g_assert_cmpint( g_list_length( result ), == , 1 ); 00885 g_assert( get_typed_referring_object_list_struct.get_typed_referring_object_list_called ); 00886 g_list_free( result ); 00887 00888 /* clean */ 00889 g_object_unref( inst ); 00890 g_object_unref( ref ); 00891 qof_book_destroy( book ); 00892 } 00893 00894 static struct 00895 { 00896 guint refers_to_object_call_count; 00897 guint get_typed_referring_object_list_count; 00898 } get_referring_object_list_struct; 00899 00900 static gboolean 00901 mock_simple_refers_to_object( const QofInstance* inst, const QofInstance* ref ) 00902 { 00903 g_assert( inst ); 00904 g_assert( ref ); 00905 if ( inst->e_type == ref->e_type ) 00906 { 00907 get_referring_object_list_struct.refers_to_object_call_count++; 00908 return TRUE; 00909 } 00910 return FALSE; 00911 } 00912 00913 static GList* 00914 mock_simple_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref) 00915 { 00916 g_assert( inst ); 00917 g_assert( ref ); 00918 get_referring_object_list_struct.get_typed_referring_object_list_count++; 00919 return qof_instance_get_referring_object_list_from_collection(qof_instance_get_collection(inst), ref); 00920 } 00921 00922 static void 00923 test_instance_get_referring_object_list( void ) 00924 { 00925 /* walk through the book's each collection's each instance */ 00926 QofInstance *ref1; 00927 QofInstance *ref2; 00928 QofBook *book; 00929 QofIdType type1 = "type1"; 00930 QofIdType type2 = "type2"; 00931 gint32 col1_length = g_test_rand_int_range( 0, 10 ); 00932 gint32 col2_length = g_test_rand_int_range( 0, 10 ); 00933 GList* inst_list1 = NULL; 00934 GList* inst_list2 = NULL; 00935 GList* result = NULL; 00936 int i, j; 00937 00938 /* setup */ 00939 book = qof_book_new(); 00940 g_assert( book ); 00941 g_assert( QOF_IS_BOOK( book ) ); 00942 ref1 = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00943 g_assert( ref1 ); 00944 ref2 = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00945 g_assert( ref2 ); 00946 qof_instance_init_data( ref1, type1, book ); 00947 qof_instance_init_data( ref2, type2, book ); 00948 QOF_INSTANCE_GET_CLASS( ref1 )->refers_to_object = NULL; 00949 QOF_INSTANCE_GET_CLASS( ref1 )->get_typed_referring_object_list = NULL; 00950 g_assert_cmpint( qof_collection_count( qof_book_get_collection( book, type1 ) ), == , 1 ); 00951 g_assert_cmpint( qof_collection_count( qof_book_get_collection( book, type2 ) ), == , 1 ); 00952 get_referring_object_list_struct.refers_to_object_call_count = 0; 00953 get_referring_object_list_struct.get_typed_referring_object_list_count = 0; 00954 /* 00955 * fill two collections with different types 00956 * and random number of elements 00957 */ 00958 for (i = 0; i < col1_length; i++ ) 00959 { 00960 QofInstance *inst = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00961 g_assert( inst ); 00962 qof_instance_init_data( inst, type1, book ); 00963 inst_list1 = g_list_append ( inst_list1, inst ); 00964 g_assert_cmpint( g_list_length( inst_list1 ), == , (i + 1) ); 00965 } 00966 g_assert_cmpint( qof_collection_count( qof_book_get_collection( book, type1 ) ), == , col1_length + 1 ); 00967 g_assert_cmpint( g_list_length( inst_list1 ), == , col1_length ); 00968 00969 for (j = 0; j < col2_length; j++ ) 00970 { 00971 QofInstance *inst = g_object_new( QOF_TYPE_INSTANCE, NULL ); 00972 g_assert( inst ); 00973 qof_instance_init_data( inst, type2, book ); 00974 inst_list2 = g_list_append ( inst_list2, inst ); 00975 g_assert_cmpint( g_list_length( inst_list2 ), == , (j + 1) ); 00976 } 00977 g_assert_cmpint( qof_collection_count( qof_book_get_collection( book, type2 ) ), == , col2_length + 1 ); 00978 g_assert_cmpint( g_list_length( inst_list2 ), == , col2_length ); 00979 00980 g_test_message( "Test object list returned for ref1 instance by default" ); 00981 result = qof_instance_get_referring_object_list( ref1 ); 00982 g_assert( !result ); 00983 g_assert_cmpint( get_referring_object_list_struct.refers_to_object_call_count, == , 0 ); 00984 00985 g_test_message( "Test object list returned for ref2 instance by default" ); 00986 result = qof_instance_get_referring_object_list( ref2 ); 00987 g_assert( !result ); 00988 g_assert_cmpint( get_referring_object_list_struct.refers_to_object_call_count, == , 0 ); 00989 00990 /* 00991 * refers to object is made simple as it is tested enough 00992 * it checks if instance types are equal 00993 * that is for ref1 we should get all elements from collection with type1 00994 * for ref2 we should get all elements from collection with type2 00995 */ 00996 g_test_message( "Test object list returned for ref1 instance when refers_to_object is set" ); 00997 QOF_INSTANCE_GET_CLASS( ref1 )->refers_to_object = mock_simple_refers_to_object; 00998 result = qof_instance_get_referring_object_list( ref1 ); 00999 g_assert( result ); 01000 g_assert_cmpint( g_list_length( result ), == , col1_length + 1 ); 01001 g_assert_cmpint( get_referring_object_list_struct.refers_to_object_call_count, == , col1_length + 1 ); 01002 g_list_free( result ); 01003 01004 g_test_message( "Test object list returned for ref2 instance when refers_to_object is set" ); 01005 get_referring_object_list_struct.refers_to_object_call_count = 0; 01006 result = qof_instance_get_referring_object_list( ref2 ); 01007 g_assert( result ); 01008 g_assert_cmpint( g_list_length( result ), == , col2_length + 1 ); 01009 g_assert_cmpint( get_referring_object_list_struct.refers_to_object_call_count, == , col2_length + 1 ); 01010 g_list_free( result ); 01011 01012 g_test_message( "Test object list returned for ref1 instance when refers_to_object is set and get typed set" ); 01013 QOF_INSTANCE_GET_CLASS( ref1 )->get_typed_referring_object_list = mock_simple_get_typed_referring_object_list; 01014 get_referring_object_list_struct.refers_to_object_call_count = 0; 01015 get_referring_object_list_struct.get_typed_referring_object_list_count = 0; 01016 result = qof_instance_get_referring_object_list( ref1 ); 01017 g_assert( result ); 01018 g_assert_cmpint( g_list_length( result ), == , col1_length + 1 ); 01019 g_assert_cmpint( get_referring_object_list_struct.refers_to_object_call_count, == , col1_length + 1 ); 01020 g_assert_cmpint( get_referring_object_list_struct.get_typed_referring_object_list_count, == , 2 ); 01021 g_list_free( result ); 01022 01023 g_test_message( "Test object list returned for ref2 instance when refers_to_object is set and get typed set" ); 01024 get_referring_object_list_struct.refers_to_object_call_count = 0; 01025 get_referring_object_list_struct.get_typed_referring_object_list_count = 0; 01026 result = qof_instance_get_referring_object_list( ref2 ); 01027 g_assert( result ); 01028 g_assert_cmpint( g_list_length( result ), == , col2_length + 1 ); 01029 g_assert_cmpint( get_referring_object_list_struct.refers_to_object_call_count, == , col2_length + 1 ); 01030 g_assert_cmpint( get_referring_object_list_struct.get_typed_referring_object_list_count, == , 2 ); 01031 g_list_free( result ); 01032 01033 /* clean */ 01034 g_object_unref( ref1 ); 01035 g_object_unref( ref2 ); 01036 g_list_foreach( inst_list1, (GFunc) g_object_unref, NULL ); 01037 g_list_foreach( inst_list2, (GFunc) g_object_unref, NULL ); 01038 g_list_free( inst_list1 ); 01039 g_list_free( inst_list2 ); 01040 qof_book_destroy( book ); 01041 } 01042 01043 void 01044 test_suite_qofinstance ( void ) 01045 { 01046 GNC_TEST_ADD( suitename, "set get book", Fixture, NULL, setup, test_instance_set_get_book, teardown ); 01047 GNC_TEST_ADD( suitename, "set get guid", Fixture, NULL, setup, test_instance_set_get_guid, teardown ); 01048 GNC_TEST_ADD_FUNC( suitename, "instance new and destroy", test_instance_new_destroy ); 01049 GNC_TEST_ADD_FUNC( suitename, "init data", test_instance_init_data ); 01050 GNC_TEST_ADD( suitename, "get set slots", Fixture, NULL, setup, test_instance_get_set_slots, teardown ); 01051 GNC_TEST_ADD_FUNC( suitename, "version compare", test_instance_version_cmp ); 01052 GNC_TEST_ADD( suitename, "get set dirty", Fixture, NULL, setup, test_instance_get_set_dirty, teardown ); 01053 GNC_TEST_ADD( suitename, "display name", Fixture, NULL, setup, test_instance_display_name, teardown ); 01054 GNC_TEST_ADD( suitename, "begin edit", Fixture, NULL, setup, test_instance_begin_edit, teardown ); 01055 GNC_TEST_ADD( suitename, "commit edit", Fixture, NULL, setup, test_instance_commit_edit, teardown ); 01056 GNC_TEST_ADD( suitename, "commit edit part 2", Fixture, NULL, setup, test_instance_commit_edit_part2, teardown ); 01057 GNC_TEST_ADD( suitename, "instance refers to object", Fixture, NULL, setup, test_instance_refers_to_object, teardown ); 01058 GNC_TEST_ADD_FUNC( suitename, "instance get referring object list from collection", test_instance_get_referring_object_list_from_collection ); 01059 GNC_TEST_ADD_FUNC( suitename, "instance get typed referring object list", test_instance_get_typed_referring_object_list); 01060 GNC_TEST_ADD_FUNC( suitename, "instance get referring object list", test_instance_get_referring_object_list ); 01061 }
1.7.4