GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
TestErrorStruct Struct Reference

#include <unittest-support.h>

Data Fields

GLogLevelFlags log_level
 
gchar * log_domain
 
gchar * msg
 
guint hits
 

Detailed Description

Suppressing Expected Errors

Functions for suppressing expected errors during tests. Pass

Note that you need to call both g_log_set_handler and g_test_log_set_fatal_handler to both avoid the assertion and suppress the error message. The callbacks work in either role, just cast them appropriately for the use.

To simplify the process a bit and make sure that everything gets cleaned up at the end of each test, add a GSList for handlers to your Fixture and set it to NULL in setup(), then call g_slist_free_full() on it with test_free_log_handler as the function. Create new TestErrorStruct instances with test_error_struct_new, and pass that along with your handler of choice to test_log_set_handler or test_log_set_fatal_handler. This is much simpler, as teardown will clean everything up for you and you need call only those functions. As an added bonus, the hit count won't be doubled as it is if you do everything by hand.

NB: If you have more than one fatal error in a test function be sure to use the test_list_handler: You can have only one fatal handler. Struct to pass as user_data for the handlers. Setting a parameter to NULL or 0 will match any value in the error, so if you have the same message and log level being issued in two domains you can match both of them by setting log_domain = NULL.

Definition at line 87 of file unittest-support.h.


The documentation for this struct was generated from the following file: