Fix some glib docs warnings
[platform/upstream/glib.git] / glib / gtestutils.c
index a6888de..c5754ec 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+
 #include "config.h"
+
 #include "gtestutils.h"
-#include <glib.h>
-#include "galias.h"
+
 #include <sys/types.h>
 #ifdef G_OS_UNIX
 #include <sys/wait.h>
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif /* HAVE_SYS_SELECT_H */
+
+#include "gmain.h"
+#include "gpattern.h"
+#include "grand.h"
+#include "gstrfuncs.h"
+#include "gtimer.h"
+
  
 /* Global variable for storing assertion messages; this is the counterpart to
  * glibc's (private) __abort_msg variable, and allows developers and crash
@@ -898,12 +906,12 @@ g_test_run (void)
  * Since: 2.16
  */
 GTestCase*
-g_test_create_case (const char     *test_name,
-                    gsize           data_size,
-                    gconstpointer   test_data,
-                    void          (*data_setup) (void),
-                    void          (*data_test) (void),
-                    void          (*data_teardown) (void))
+g_test_create_case (const char       *test_name,
+                    gsize             data_size,
+                    gconstpointer     test_data,
+                    GTestFixtureFunc  data_setup,
+                    GTestFixtureFunc  data_test,
+                    GTestFixtureFunc  data_teardown)
 {
   GTestCase *tc;
   g_return_val_if_fail (test_name != NULL, NULL);
@@ -920,13 +928,29 @@ g_test_create_case (const char     *test_name,
   return tc;
 }
 
+/**
+ * GTestFixtureFunc:
+ * @fixture: the test fixture
+ * @user_data: the data provided when registering the test
+ *
+ * The type used for functions that operate on test fixtures.  This is
+ * used for the fixture setup and teardown functions as well as for the
+ * testcases themselves.
+ *
+ * @user_data is a pointer to the data that was given when registering
+ * the test case.
+ *
+ * @fixture will be a pointer to the area of memory allocated by the
+ * test framework, of the size requested.  If the requested size was
+ * zero then @fixture will be equal to @user_data.
+ **/
 void
-g_test_add_vtable (const char     *testpath,
-                   gsize           data_size,
-                   gconstpointer   test_data,
-                   void          (*data_setup)    (void),
-                   void          (*fixture_test_func) (void),
-                   void          (*data_teardown) (void))
+g_test_add_vtable (const char       *testpath,
+                   gsize             data_size,
+                   gconstpointer     test_data,
+                   GTestFixtureFunc  data_setup,
+                   GTestFixtureFunc  fixture_test_func,
+                   GTestFixtureFunc  data_teardown)
 {
   gchar **segments;
   guint ui;
@@ -962,6 +986,11 @@ g_test_add_vtable (const char     *testpath,
 }
 
 /**
+ * GTestFunc:
+ *
+ * The type used for test case functions.
+ **/
+/**
  * g_test_add_func:
  * @testpath:   Slash-separated test case path name for the test.
  * @test_func:  The test function to invoke for this test.
@@ -974,16 +1003,23 @@ g_test_add_vtable (const char     *testpath,
  * Since: 2.16
  */
 void
-g_test_add_func (const char     *testpath,
-                 void          (*test_func) (void))
+g_test_add_func (const char *testpath,
+                 GTestFunc   test_func)
 {
   g_return_if_fail (testpath != NULL);
   g_return_if_fail (testpath[0] == '/');
   g_return_if_fail (test_func != NULL);
-  g_test_add_vtable (testpath, 0, NULL, NULL, test_func, NULL);
+  g_test_add_vtable (testpath, 0, NULL, NULL, (GTestFixtureFunc) test_func, NULL);
 }
 
 /**
+ * GTestDataFunc:
+ * @user_data: the data provided when registering the test
+ *
+ * The type used for test case functions that take an extra pointer
+ * argument.
+ **/
+/**
  * g_test_add_data_func:
  * @testpath:   Slash-separated test case path name for the test.
  * @test_data:  Test data argument for the test function.
@@ -1000,12 +1036,12 @@ g_test_add_func (const char     *testpath,
 void
 g_test_add_data_func (const char     *testpath,
                       gconstpointer   test_data,
-                      void          (*test_func) (gconstpointer))
+                      GTestDataFunc   test_func)
 {
   g_return_if_fail (testpath != NULL);
   g_return_if_fail (testpath[0] == '/');
   g_return_if_fail (test_func != NULL);
-  g_test_add_vtable (testpath, 0, test_data, NULL, (void(*)(void)) test_func, NULL);
+  g_test_add_vtable (testpath, 0, test_data, NULL, (GTestFixtureFunc) test_func, NULL);
 }
 
 /**
@@ -1255,6 +1291,7 @@ gtest_default_log_handler (const gchar    *log_domain,
                            gpointer        unused_data)
 {
   const gchar *strv[16];
+  gboolean fatal = FALSE;
   gchar *msg;
   guint i = 0;
   if (log_domain)
@@ -1263,7 +1300,10 @@ gtest_default_log_handler (const gchar    *log_domain,
       strv[i++] = "-";
     }
   if (log_level & G_LOG_FLAG_FATAL)
-    strv[i++] = "FATAL-";
+    {
+      strv[i++] = "FATAL-";
+      fatal = TRUE;
+    }
   if (log_level & G_LOG_FLAG_RECURSION)
     strv[i++] = "RECURSIVE-";
   if (log_level & G_LOG_LEVEL_ERROR)
@@ -1282,7 +1322,7 @@ gtest_default_log_handler (const gchar    *log_domain,
   strv[i++] = message;
   strv[i++] = NULL;
   msg = g_strjoinv ("", (gchar**) strv);
-  g_test_log (G_TEST_LOG_ERROR, msg, NULL, 0, NULL);
+  g_test_log (fatal ? G_TEST_LOG_ERROR : G_TEST_LOG_MESSAGE, msg, NULL, 0, NULL);
   g_log_default_handler (log_domain, log_level, message, unused_data);
   g_free (msg);
 }
@@ -1381,7 +1421,7 @@ g_assertion_message_error (const char     *domain,
                           int             line,
                           const char     *func,
                           const char     *expr,
-                          GError         *error,
+                          const GError   *error,
                           GQuark          error_domain,
                           int             error_code)
 {
@@ -1416,6 +1456,7 @@ g_assertion_message_error (const char     *domain,
  *
  * Compares @str1 and @str2 like strcmp(). Handles %NULL 
  * gracefully by sorting it before non-%NULL strings.
+ * Comparing two %NULL pointers returns 0.
  *
  * Returns: -1, 0 or 1, if @str1 is <, == or > than @str2.
  *
@@ -2024,6 +2065,3 @@ g_test_log_msg_free (GTestLogMsg *tmsg)
  * Since: 2.16
  **/
 /* --- macros docs END --- */
-
-#define __G_TEST_UTILS_C__
-#include "galiasdef.c"