* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __G_TEST_UTILS_H__
#define g_assert_error(err, dom, c) do { if (!err || (err)->domain != dom || (err)->code != c) \
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#err, err, dom, c); } while (0)
+#define g_assert_true(expr) do { if G_LIKELY (expr) ; else \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+ "'" #expr "' should be TRUE"); \
+ } while (0)
+#define g_assert_false(expr) do { if G_LIKELY (!(expr)) ; else \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+ "'" #expr "' should be FALSE"); \
+ } while (0)
+#define g_assert_null(expr) do { if G_LIKELY ((expr) == NULL) ; else \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+ "'" #expr "' should be NULL"); \
+ } while (0)
+#define g_assert_nonnull(expr) do { if G_LIKELY ((expr) != NULL) ; else \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+ "'" #expr "' should not be NULL"); \
+ } while (0)
#ifdef G_DISABLE_ASSERT
#define g_assert_not_reached() do { (void) 0; } while (0)
#define g_assert(expr) do { (void) 0; } while (0)
+#define g_assert_se(expr) ((void) (expr))
#else /* !G_DISABLE_ASSERT */
-#define g_assert_not_reached() do { g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
+#define g_assert_not_reached() do { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
#define g_assert(expr) do { if G_LIKELY (expr) ; else \
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #expr); } while (0)
+ #expr); \
+ } while (0)
+#define g_assert_se(expr) g_assert((expr))
#endif /* !G_DISABLE_ASSERT */
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_ALL
void g_test_init (int *argc,
char ***argv,
- ...);
+ ...) G_GNUC_NULL_TERMINATED;
/* query testing framework config */
#define g_test_initialized() (g_test_config_vars->test_initialized)
#define g_test_quick() (g_test_config_vars->test_quick)
#define g_test_verbose() (g_test_config_vars->test_verbose)
#define g_test_quiet() (g_test_config_vars->test_quiet)
#define g_test_undefined() (g_test_config_vars->test_undefined)
+GLIB_AVAILABLE_IN_2_38
+gboolean g_test_subprocess (void);
+
/* run all tests under toplevel suite (path: /) */
GLIB_AVAILABLE_IN_ALL
int g_test_run (void);
/* tell about failure */
GLIB_AVAILABLE_IN_2_30
void g_test_fail (void);
+GLIB_AVAILABLE_IN_2_38
+void g_test_incomplete (const gchar *msg);
+GLIB_AVAILABLE_IN_2_38
+void g_test_skip (const gchar *msg);
+GLIB_AVAILABLE_IN_2_38
+gboolean g_test_failed (void);
+GLIB_AVAILABLE_IN_2_38
+void g_test_set_nonfatal_assertions (void);
/* hook up a test with fixture under test path */
#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
gpointer destroy_data);
#define g_test_queue_unref(gobject) g_test_queue_destroy (g_object_unref, gobject)
-/* test traps are guards used around forked tests */
typedef enum {
G_TEST_TRAP_SILENCE_STDOUT = 1 << 7,
G_TEST_TRAP_SILENCE_STDERR = 1 << 8,
G_TEST_TRAP_INHERIT_STDIN = 1 << 9
} GTestTrapFlags;
-GLIB_AVAILABLE_IN_ALL
+
+GLIB_DEPRECATED_IN_2_38_FOR (g_test_trap_subprocess)
gboolean g_test_trap_fork (guint64 usec_timeout,
GTestTrapFlags test_trap_flags);
+
+typedef enum {
+ G_TEST_SUBPROCESS_INHERIT_STDIN = 1 << 0,
+ G_TEST_SUBPROCESS_INHERIT_STDOUT = 1 << 1,
+ G_TEST_SUBPROCESS_INHERIT_STDERR = 1 << 2
+} GTestSubprocessFlags;
+
+GLIB_AVAILABLE_IN_2_38
+void g_test_trap_subprocess (const char *test_path,
+ guint64 usec_timeout,
+ GTestSubprocessFlags test_flags);
+
GLIB_AVAILABLE_IN_ALL
gboolean g_test_trap_has_passed (void);
GLIB_AVAILABLE_IN_ALL
const char *file,
int line,
const char *func,
- const char *message) G_GNUC_NORETURN;
+ const char *message);
GLIB_AVAILABLE_IN_ALL
void g_assertion_message_expr (const char *domain,
const char *file,
const char *expr,
const char *arg1,
const char *cmp,
- const char *arg2) G_GNUC_NORETURN;
+ const char *arg2);
GLIB_AVAILABLE_IN_ALL
void g_assertion_message_cmpnum (const char *domain,
const char *file,
long double arg1,
const char *cmp,
long double arg2,
- char numtype) G_GNUC_NORETURN;
+ char numtype);
GLIB_AVAILABLE_IN_ALL
void g_assertion_message_error (const char *domain,
const char *file,
const char *expr,
const GError *error,
GQuark error_domain,
- int error_code) G_GNUC_NORETURN;
+ int error_code);
GLIB_AVAILABLE_IN_ALL
void g_test_add_vtable (const char *testpath,
gsize data_size,
G_TEST_LOG_STOP_CASE, /* d:status d:nforks d:elapsed */
G_TEST_LOG_MIN_RESULT, /* s:blurb d:result */
G_TEST_LOG_MAX_RESULT, /* s:blurb d:result */
- G_TEST_LOG_MESSAGE /* s:blurb */
+ G_TEST_LOG_MESSAGE, /* s:blurb */
+ G_TEST_LOG_START_SUITE,
+ G_TEST_LOG_STOP_SUITE
} GTestLogType;
typedef struct {
*
* Specifies the prototype of fatal log handler functions.
*
- * Return value: %TRUE if the program should abort, %FALSE otherwise
+ * Returns: %TRUE if the program should abort, %FALSE otherwise
*
* Since: 2.22
*/
g_test_log_set_fatal_handler (GTestLogFatalFunc log_func,
gpointer user_data);
-GLIB_AVAILABLE_IN_ALL
+GLIB_AVAILABLE_IN_2_34
void g_test_expect_message (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *pattern);
-GLIB_AVAILABLE_IN_ALL
+GLIB_AVAILABLE_IN_2_34
void g_test_assert_expected_messages_internal (const char *domain,
const char *file,
int line,
const char *func);
+typedef enum
+{
+ G_TEST_DIST,
+ G_TEST_BUILT
+} GTestFileType;
+
+GLIB_AVAILABLE_IN_2_38
+gchar * g_test_build_filename (GTestFileType file_type,
+ const gchar *first_path,
+ ...) G_GNUC_NULL_TERMINATED;
+GLIB_AVAILABLE_IN_2_38
+const gchar *g_test_get_dir (GTestFileType file_type);
+GLIB_AVAILABLE_IN_2_38
+const gchar *g_test_get_filename (GTestFileType file_type,
+ const gchar *first_path,
+ ...) G_GNUC_NULL_TERMINATED;
+
#define g_test_assert_expected_messages() g_test_assert_expected_messages_internal (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC)
G_END_DECLS