[Testing] Stifle error messages from QOF testing.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21702 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2011-12-09 23:50:03 +00:00
parent c0a831f9be
commit 3df0b35b4f
3 changed files with 36 additions and 1 deletions

View File

@ -31,7 +31,10 @@ test_qofdir = ${GNC_LIBEXECDIR}/${MODULEPATH}/test
#The tests might require more libraries, but try to keep them
#as independent as possible.
test_qof_LDADD = ${top_builddir}/${MODULEPATH}/libgnc-qof.la $(GLIB_LIBS)
test_qof_LDADD = \
${top_builddir}/${MODULEPATH}/libgnc-qof.la \
${top_builddir}/src/test-core/.libs/libtest-core.la \
$(GLIB_LIBS)
test_qof_CFLAGS = \
${DEFAULT_INCLUDES} \

View File

@ -550,9 +550,19 @@ test_book_foreach_collection( Fixture *fixture, gconstpointer pData )
QofCollection *m_col, *m_col2;
QofIdType my_type = "my_type", my_type2 = "my_type2";
guint param = (guint) g_test_rand_int();
gchar *msg1 = "qof_book_foreach_collection: assertion `book' failed";
gchar *msg2 = "qof_book_foreach_collection: assertion `cb' failed";
gchar *log_domain = "qof";
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL, hdlr;
TestErrorStruct check1 = { loglevel, log_domain, msg1 };
TestErrorStruct check2 = { loglevel, log_domain, msg2 };
/* need this as long as we have fatal warnings enabled */
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )handle_faults, NULL );
test_add_error (&check1);
test_add_error (&check2);
hdlr = g_log_set_handler (log_domain, loglevel,
(GLogFunc)test_list_handler, NULL);
g_test_message( "Testing when book is null" );
m_col = qof_book_get_collection( fixture->book, my_type );
@ -574,6 +584,8 @@ test_book_foreach_collection( Fixture *fixture, gconstpointer pData )
g_assert( !col_struct.col2_called );
g_assert_cmpstr( test_struct.msg, == , "qof_book_foreach_collection: assertion `cb' failed" );
g_free( test_struct.msg );
g_log_remove_handler (log_domain, hdlr);
test_clear_error_list ();
g_test_message( "Testing when book and cb not null, user_data provided" );
/* both cols have to be called */

View File

@ -116,6 +116,13 @@ test_instance_new_destroy( void )
QofInstanceClass *klass;
/* test var */
Timespec *timespec_priv;
gchar *msg1 = "qof_instance_get_collection: assertion `QOF_IS_INSTANCE(ptr)' failed";
gchar *msg2 = "qof_instance_get_editlevel: assertion `QOF_IS_INSTANCE(ptr)' failed";
gchar *msg3 = "qof_instance_get_destroying: assertion `QOF_IS_INSTANCE(ptr)' failed";
gchar *msg4 = "qof_instance_get_dirty_flag: assertion `QOF_IS_INSTANCE(ptr)' failed";
gchar *log_domain = "qof";
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL, hdlr;
TestErrorStruct check = { loglevel, log_domain, msg1 };
g_test_message( "Testing qofinstance object initialization" );
inst = g_object_new(QOF_TYPE_INSTANCE, NULL);
@ -149,21 +156,27 @@ test_instance_new_destroy( void )
g_assert( !QOF_IS_INSTANCE( inst ) );
/* set fatal handler */
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )fatal_handler, NULL );
hdlr = g_log_set_handler (log_domain, loglevel,
(GLogFunc)test_checked_handler, &check);
g_assert( qof_instance_get_collection( inst ) == NULL );
g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL );
g_free( error_message );
check.msg = msg2;
g_assert_cmpint( qof_instance_get_editlevel( inst ), == , 0 );
g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL );
g_free( error_message );
check.msg = msg3;
g_assert( !qof_instance_get_destroying( inst ) );
g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL );
g_free( error_message );
check.msg = msg4;
g_assert( !qof_instance_get_dirty_flag( inst ) );
g_assert( g_strrstr( error_message, "assertion `QOF_IS_INSTANCE(ptr)' failed" ) != NULL );
g_free( error_message );
g_log_remove_handler (log_domain, hdlr);
}
static void
@ -479,6 +492,10 @@ static void
test_instance_commit_edit( Fixture *fixture, gconstpointer pData )
{
gboolean result;
gchar *msg = "[qof_commit_edit()] unbalanced call - resetting (was -2)";
gchar *log_domain = "qof.engine";
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL, hdlr;
TestErrorStruct check = { loglevel, log_domain, msg };
g_test_message( "Test when instance set to null" );
result = qof_commit_edit( NULL );
@ -499,12 +516,15 @@ test_instance_commit_edit( Fixture *fixture, gconstpointer pData )
g_test_message( "Test when instance's editlevel < 0" );
g_test_log_set_fatal_handler ( ( GTestLogFatalFunc )fatal_handler, NULL );
hdlr = g_log_set_handler (log_domain, loglevel,
(GLogFunc)test_checked_handler, &check);
qof_instance_decrease_editlevel( fixture->inst );
g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , -1 );
result = qof_commit_edit( fixture->inst );
g_assert_cmpint( qof_instance_get_editlevel( fixture->inst ), == , 0 );
g_assert_cmpstr( error_message, == , "[qof_commit_edit()] unbalanced call - resetting (was -2)" );
g_free( error_message );
g_log_remove_handler (log_domain, hdlr);
}
/* backend commit test start */