23 #ifndef UNITTEST_SUPPORT_H 24 #define UNITTEST_SUPPORT_H 50 #define GNC_TEST_ADD( suite, path, fixture, data, setup, test, teardown )\ 52 gchar *testpath = g_strdup_printf( "%s/%s", suite, path );\ 53 g_test_add( testpath, fixture, data, setup, test, teardown );\ 61 #define GNC_TEST_ADD_FUNC( suite, path, test )\ 63 gchar *testpath = g_strdup_printf( "%s/%s", suite, path );\ 64 g_test_add_func( testpath, test );\ 104 GLogLevelFlags log_level;
124 const GLogLevelFlags log_level,
142 gboolean list_handler;
193 const gchar *msg, gpointer user_data);
201 const gchar *msg, gpointer user_data);
209 gboolean
test_log_handler (
const char *log_domain, GLogLevelFlags log_level,
210 const gchar *msg, gpointer user_data);
216 const gchar *msg, gpointer user_data );
227 void test_clear_error_list (
void);
239 const gchar *msg, gpointer user_data);
249 GLogLevelFlags log_level,
250 const gchar *msg, gpointer user_data );
311 gpointer event_data);
322 #define test_signal_assert_hits(sig, hits) \ 323 g_assert_cmpint (test_signal_return_hits (sig), ==, hits) 353 #define test_destroy(obj) \ 354 g_assert_true (obj != NULL && G_IS_OBJECT (obj)); \ 355 g_assert_true (test_object_checked_destroy (G_OBJECT (obj))) gboolean test_list_handler(const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
Checks received errors against the list created by test_add_error.
void test_free_log_handler(gpointer item)
Clears all the log handlers.
gboolean test_checked_handler(const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
Check the user_data against the actual error and assert on any differences.
Holds a handler instance with its TestErrorStruct, handler id, and whether it's a list handler...
gboolean test_checked_substring_handler(const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
Check that the user_data error message is a substring of the actual error otherwise assert...
guint test_signal_return_hits(TestSignal sig)
gets the number of times the TestSignal has been called.
void test_set_data(gpointer data)
Set the test data pointer with the what you expect your mock to be called with.
gboolean test_log_handler(const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
Just print the log message.
void test_signal_free(TestSignal sig)
Free a test signal.
gboolean test_object_checked_destroy(GObject *obj)
Unrefs obj and returns true if its finalize method was called.
TestErrorStruct * test_error_struct_new(const char *log_domain, const GLogLevelFlags log_level, const char *msg)
Convenience function to create an error struct.
gint QofEventId
Define the type of events allowed.
gboolean test_reset_called(void)
Destructively tests (meaning that it resets called to FALSE) and returns the value of called...
gboolean test_null_handler(const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
Just returns FALSE or suppresses the message regardless of what the error is.
gboolean test_list_substring_handler(const char *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
Checks received errors against the list created by test_add_error.
void test_free(gpointer data)
A handy function to use to free memory from lists of simple pointers.
gpointer test_reset_data(void)
Destructively retrieves the test data pointer.
Struct to pass as user_data for the handlers.
GSList * test_log_set_fatal_handler(GSList *list, TestErrorStruct *error, GLogFunc handler)
Set a log handler and add it to a GList for removal at teardown; also set the fatal handler so that t...
GSList * test_log_set_handler(GSList *list, TestErrorStruct *error, GLogFunc handler)
Set a log handler and add it to a GList for removal at teardown.
void test_error_struct_free(TestErrorStruct *)
Free a TestErrorStruct created with test_error_struct_new.
TestSignal test_signal_new(QofInstance *entity, QofEventId eventType, gpointer event_data)
Create a test signal.
void test_set_called(const gboolean val)
Call this from a mock object to indicate that the mock has in fact been called.
gpointer TestSignal
TestSignal is an opaque struct used to mock handling signals emitted by functions-under-test.
void test_add_error(TestErrorStruct *error)
Maintains an internal list of TestErrorStructs which are each checked by the list handler...