blob: 255c91e65b0b4869974c1381fba344ac0f4b8bac [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testing: GLib Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-Bookmark-file-parser.html" title="Bookmark file parser">
<link rel="next" href="glib-UNIX-specific-utilities-and-integration.html" title="UNIX-specific utilities and integration">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
<a href="#glib-Testing.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-Bookmark-file-parser.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="glib-UNIX-specific-utilities-and-integration.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-Testing"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Testing.top_of_page"></a>Testing</span></h2>
<p>Testing — a test framework</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="glib-Testing.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-minimized-result" title="g_test_minimized_result ()">g_test_minimized_result</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-maximized-result" title="g_test_maximized_result ()">g_test_maximized_result</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()">g_test_init</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-initialized" title="g_test_initialized">g_test_initialized</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick">g_test_quick</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow">g_test_slow</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-thorough" title="g_test_thorough">g_test_thorough</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-perf" title="g_test_perf">g_test_perf</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose">g_test_verbose</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-undefined" title="g_test_undefined">g_test_undefined</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet">g_test_quiet</a></td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-subprocess" title="g_test_subprocess ()">g_test_subprocess</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">int</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()">g_test_run</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Testing.html#GTestFunc" title="GTestFunc ()">*GTestFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()">g_test_add_func</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()">*GTestDataFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-add-data-func" title="g_test_add_data_func ()">g_test_add_data_func</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-add-data-func-full" title="g_test_add_data_func_full ()">g_test_add_data_func_full</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()">g_test_add</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-build-filename" title="g_test_build_filename ()">g_test_build_filename</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-get-filename" title="g_test_get_filename ()">g_test_get_filename</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-get-dir" title="g_test_get_dir ()">g_test_get_dir</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-fail" title="g_test_fail ()">g_test_fail</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-skip" title="g_test_skip ()">g_test_skip</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-incomplete" title="g_test_incomplete ()">g_test_incomplete</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-failed" title="g_test_failed ()">g_test_failed</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-message" title="g_test_message ()">g_test_message</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-bug-base" title="g_test_bug_base ()">g_test_bug_base</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-bug" title="g_test_bug ()">g_test_bug</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Testing.html#GTestLogFatalFunc" title="GTestLogFatalFunc ()">*GTestLogFatalFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-log-set-fatal-handler" title="g_test_log_set_fatal_handler ()">g_test_log_set_fatal_handler</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-timer-start" title="g_test_timer_start ()">g_test_timer_start</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">double</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()">g_test_timer_elapsed</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">double</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-timer-last" title="g_test_timer_last ()">g_test_timer_last</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-queue-free" title="g_test_queue_free ()">g_test_queue_free</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()">g_test_queue_destroy</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-queue-unref" title="g_test_queue_unref()">g_test_queue_unref</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()">g_test_expect_message</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-assert-expected-messages" title="g_test_assert_expected_messages">g_test_assert_expected_messages</a></td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()">g_test_trap_subprocess</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-has-passed" title="g_test_trap_has_passed ()">g_test_trap_has_passed</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-reached-timeout" title="g_test_trap_reached_timeout ()">g_test_trap_reached_timeout</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-trap-assert-passed" title="g_test_trap_assert_passed">g_test_trap_assert_passed</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-trap-assert-failed" title="g_test_trap_assert_failed">g_test_trap_assert_failed</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()">g_test_trap_assert_stdout</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-assert-stdout-unmatched" title="g_test_trap_assert_stdout_unmatched()">g_test_trap_assert_stdout_unmatched</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()">g_test_trap_assert_stderr</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-assert-stderr-unmatched" title="g_test_trap_assert_stderr_unmatched()">g_test_trap_assert_stderr_unmatched</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()">g_test_trap_fork</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-test-rand-bit" title="g_test_rand_bit">g_test_rand_bit</a></td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()">g_test_rand_int</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-rand-int-range" title="g_test_rand_int_range ()">g_test_rand_int_range</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">double</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-rand-double" title="g_test_rand_double ()">g_test_rand_double</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">double</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-rand-double-range" title="g_test_rand_double_range ()">g_test_rand_double_range</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert" title="g_assert()">g_assert</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Testing.html#g-assert-not-reached" title="g_assert_not_reached">g_assert_not_reached</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-cmpstr" title="g_assert_cmpstr()">g_assert_cmpstr</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-cmpint" title="g_assert_cmpint()">g_assert_cmpint</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()">g_assert_cmpuint</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-cmphex" title="g_assert_cmphex()">g_assert_cmphex</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-cmpfloat" title="g_assert_cmpfloat()">g_assert_cmpfloat</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-cmpmem" title="g_assert_cmpmem()">g_assert_cmpmem</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-no-error" title="g_assert_no_error()">g_assert_no_error</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-error" title="g_assert_error()">g_assert_error</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-true" title="g_assert_true()">g_assert_true</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-false" title="g_assert_false()">g_assert_false</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-null" title="g_assert_null()">g_assert_null</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-assert-nonnull" title="g_assert_nonnull()">g_assert_nonnull</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-set-nonfatal-assertions" title="g_test_set_nonfatal_assertions ()">g_test_set_nonfatal_assertions</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()">*GTestFixtureFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="returnvalue">GTestCase</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()">g_test_create_case</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-create-suite" title="g_test_create_suite ()">g_test_create_suite</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-get-root" title="g_test_get_root ()">g_test_get_root</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-suite-add" title="g_test_suite_add ()">g_test_suite_add</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-suite-add-suite" title="g_test_suite_add_suite ()">g_test_suite_add_suite</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">int</span>
</td>
<td class="function_name">
<a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()">g_test_run_suite</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Testing.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType">GTestFileType</a></td>
</tr>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags">GTestTrapFlags</a></td>
</tr>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags">GTestSubprocessFlags</a></td>
</tr>
<tr>
<td class="typedef_keyword">typedef</td>
<td class="function_name"><a class="link" href="glib-Testing.html#GTestCase" title="GTestCase">GTestCase</a></td>
</tr>
<tr>
<td class="typedef_keyword">typedef</td>
<td class="function_name"><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite">GTestSuite</a></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Testing.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;glib.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="glib-Testing.description"></a><h2>Description</h2>
<p>GLib provides a framework for writing and maintaining unit tests
in parallel to the code they are testing. The API is designed according
to established concepts found in the other test frameworks (JUnit, NUnit,
RUnit), which in turn is based on smalltalk unit testing concepts.</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>Test case: Tests (test methods) are grouped together with their
fixture into test cases.</p></li>
<li class="listitem"><p>Fixture: A test fixture consists of fixture data and setup and
teardown methods to establish the environment for the test
functions. We use fresh fixtures, i.e. fixtures are newly set
up and torn down around each test invocation to avoid dependencies
between tests.</p></li>
<li class="listitem"><p>Test suite: Test cases can be grouped into test suites, to allow
subsets of the available tests to be run. Test suites can be
grouped into other test suites as well.</p></li>
</ul></div>
<p>The API is designed to handle creation and registration of test suites
and test cases implicitly. A simple call like</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Testing.html#g-test-add-func">g_test_add_func</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/misc/assertions"</span><span class="symbol">,</span><span class="normal"> test_assertions</span><span class="symbol">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
creates a test suite called "misc" with a single test case named
"assertions", which consists of running the test_assertions function.</p>
<p>In addition to the traditional <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a>, the test framework provides
an extended set of assertions for comparisons: <a class="link" href="glib-Testing.html#g-assert-cmpfloat" title="g_assert_cmpfloat()"><code class="function">g_assert_cmpfloat()</code></a>,
<a class="link" href="glib-Testing.html#g-assert-cmpint" title="g_assert_cmpint()"><code class="function">g_assert_cmpint()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()"><code class="function">g_assert_cmpuint()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmphex" title="g_assert_cmphex()"><code class="function">g_assert_cmphex()</code></a>,
<a class="link" href="glib-Testing.html#g-assert-cmpstr" title="g_assert_cmpstr()"><code class="function">g_assert_cmpstr()</code></a>, and <a class="link" href="glib-Testing.html#g-assert-cmpmem" title="g_assert_cmpmem()"><code class="function">g_assert_cmpmem()</code></a>. The advantage of these
variants over plain <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a> is that the assertion messages can be
more elaborate, and include the values of the compared entities.</p>
<p>GLib ships with two utilities called gtester and
gtester-report to facilitate running tests and producing
nicely formatted test reports.</p>
<p>A full example of creating a test suite with two tests using fixtures:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="preproc">#include</span><span class="normal"> </span><span class="string">&lt;glib.h&gt;</span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string">&lt;locale.h&gt;</span>
<span class="keyword">typedef</span><span class="normal"> </span><span class="keyword">struct</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="usertype">MyObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">obj</span><span class="symbol">;</span>
<span class="normal"> </span><span class="usertype">OtherObject</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">helper</span><span class="symbol">;</span>
<span class="cbracket">}</span><span class="normal"> MyObjectFixture</span><span class="symbol">;</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">my_object_fixture_set_up</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">MyObjectFixture</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">fixture</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gconstpointer</span><span class="normal"> user_data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> fixture</span><span class="symbol">-&gt;</span><span class="normal">obj </span><span class="symbol">=</span><span class="normal"> </span><span class="function">my_object_new</span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function">my_object_set_prop1</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">obj</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"some-value"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function">my_object_do_some_complex_setup</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">obj</span><span class="symbol">,</span><span class="normal"> user_data</span><span class="symbol">);</span>
<span class="normal"> fixture</span><span class="symbol">-&gt;</span><span class="normal">helper </span><span class="symbol">=</span><span class="normal"> </span><span class="function">other_object_new</span><span class="normal"> </span><span class="symbol">();</span>
<span class="cbracket">}</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">my_object_fixture_tear_down</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">MyObjectFixture</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">fixture</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gconstpointer</span><span class="normal"> user_data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="function"><a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-clear-object">g_clear_object</a></span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">helper</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-clear-object">g_clear_object</a></span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">obj</span><span class="symbol">);</span>
<span class="cbracket">}</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_my_object_test1</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">MyObjectFixture</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">fixture</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gconstpointer</span><span class="normal"> user_data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-assert-cmpstr">g_assert_cmpstr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">my_object_get_property</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">obj</span><span class="symbol">),</span><span class="normal"> </span><span class="symbol">==,</span><span class="normal"> </span><span class="string">"initial-value"</span><span class="symbol">);</span>
<span class="cbracket">}</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_my_object_test2</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">MyObjectFixture</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">fixture</span><span class="symbol">,</span>
<span class="normal"> </span><span class="usertype">gconstpointer</span><span class="normal"> user_data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="function">my_object_do_some_work_using_helper</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">obj</span><span class="symbol">,</span><span class="normal"> fixture</span><span class="symbol">-&gt;</span><span class="normal">helper</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-assert-cmpstr">g_assert_cmpstr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">my_object_get_property</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">fixture</span><span class="symbol">-&gt;</span><span class="normal">obj</span><span class="symbol">),</span><span class="normal"> </span><span class="symbol">==,</span><span class="normal"> </span><span class="string">"updated-value"</span><span class="symbol">);</span>
<span class="cbracket">}</span>
<span class="type">int</span>
<span class="function">main</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> argc</span><span class="symbol">,</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">argv</span><span class="symbol">[])</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="function">setlocale</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">LC_ALL</span><span class="symbol">,</span><span class="normal"> </span><span class="string">""</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-init">g_test_init</a></span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">argc</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&amp;</span><span class="normal">argv</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-bug-base">g_test_bug_base</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"http://bugzilla.gnome.org/show_bug.cgi?id="</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">// Define the tests.</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-add">g_test_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/my-object/test1"</span><span class="symbol">,</span><span class="normal"> MyObjectFixture</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"some-user-data"</span><span class="symbol">,</span>
<span class="normal"> my_object_fixture_set_up</span><span class="symbol">,</span><span class="normal"> test_my_object_test1</span><span class="symbol">,</span>
<span class="normal"> my_object_fixture_tear_down</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-add">g_test_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/my-object/test2"</span><span class="symbol">,</span><span class="normal"> MyObjectFixture</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"some-user-data"</span><span class="symbol">,</span>
<span class="normal"> my_object_fixture_set_up</span><span class="symbol">,</span><span class="normal"> test_my_object_test2</span><span class="symbol">,</span>
<span class="normal"> my_object_fixture_tear_down</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-run">g_test_run</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
</div>
<div class="refsect1">
<a name="glib-Testing.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="g-test-minimized-result"></a><h3>g_test_minimized_result ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_minimized_result (<em class="parameter"><code><span class="type">double</span> minimized_quantity</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
<em class="parameter"><code>...</code></em>);</pre>
<p>Report the result of a performance or measurement test.
The test should generally strive to minimize the reported
quantities (smaller values are better than larger ones),
this and <em class="parameter"><code>minimized_quantity</code></em>
can determine sorting
order for test result reports.</p>
<div class="refsect3">
<a name="g-test-minimized-result.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>minimized_quantity</p></td>
<td class="parameter_description"><p>the reported value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>format</p></td>
<td class="parameter_description"><p>the format string of the report message</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>arguments to pass to the <code class="function">printf()</code> function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-maximized-result"></a><h3>g_test_maximized_result ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_maximized_result (<em class="parameter"><code><span class="type">double</span> maximized_quantity</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
<em class="parameter"><code>...</code></em>);</pre>
<p>Report the result of a performance or measurement test.
The test should generally strive to maximize the reported
quantities (larger values are better than smaller ones),
this and <em class="parameter"><code>maximized_quantity</code></em>
can determine sorting
order for test result reports.</p>
<div class="refsect3">
<a name="g-test-maximized-result.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>maximized_quantity</p></td>
<td class="parameter_description"><p>the reported value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>format</p></td>
<td class="parameter_description"><p>the format string of the report message</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>arguments to pass to the <code class="function">printf()</code> function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-init"></a><h3>g_test_init ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_init (<em class="parameter"><code><span class="type">int</span> *argc</code></em>,
<em class="parameter"><code><span class="type">char</span> ***argv</code></em>,
<em class="parameter"><code>...</code></em>);</pre>
<p>Initialize the GLib testing framework, e.g. by seeding the
test random number generator, the name for <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-get-prgname" title="g_get_prgname ()"><code class="function">g_get_prgname()</code></a>
and parsing test related command line args.</p>
<p>So far, the following arguments are understood:</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p><code class="literal">-l</code>: List test cases available in a test executable.</p></li>
<li class="listitem"><p><code class="literal">--seed=SEED</code>: Provide a random seed to reproduce test
runs using random numbers.</p></li>
<li class="listitem"><p><code class="literal">--verbose</code>: Run tests verbosely.</p></li>
<li class="listitem"><p><code class="literal">-q</code>, <code class="literal">--quiet</code>: Run tests quietly.</p></li>
<li class="listitem"><p><code class="literal">-p PATH</code>: Execute all tests matching the given path.
This can also be used to force a test to run that would otherwise
be skipped (ie, a test whose name contains "/subprocess").</p></li>
<li class="listitem">
<p><code class="literal">-m {perf|slow|thorough|quick|undefined|no-undefined}</code>: Execute tests according to these test modes:</p>
<p><code class="literal">perf</code>: Performance tests, may take long and report results.</p>
<p><code class="literal">slow</code>, <code class="literal">thorough</code>: Slow and thorough tests, may take quite long and maximize coverage.</p>
<p><code class="literal">quick</code>: Quick tests, should run really quickly and give good coverage.</p>
<p><code class="literal">undefined</code>: Tests for undefined behaviour, may provoke programming errors
under <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> or <a href="glib-Testing.html#g-test-expect-message"><code class="function">g_test_expect_messages()</code></a> to check
that appropriate assertions or warnings are given</p>
<p><code class="literal">no-undefined</code>: Avoid tests for undefined behaviour</p>
</li>
<li class="listitem"><p><code class="literal">--debug-log</code>: Debug test logging output.</p></li>
</ul></div>
<div class="refsect3">
<a name="g-test-init.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>argc</p></td>
<td class="parameter_description"><p>Address of the <em class="parameter"><code>argc</code></em>
parameter of the <code class="function">main()</code> function.
Changed if any arguments were handled.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>argv</p></td>
<td class="parameter_description"><p>Address of the <em class="parameter"><code>argv</code></em>
parameter of <code class="function">main()</code>.
Any parameters understood by <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> stripped before return.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p><a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated list of special options. Currently the only
defined option is <code class="literal">"no_g_set_prgname"</code>, which
will cause <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> to not call <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-set-prgname" title="g_set_prgname ()"><code class="function">g_set_prgname()</code></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-initialized"></a><h3>g_test_initialized</h3>
<pre class="programlisting">#define g_test_initialized()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> has been called.</p>
<div class="refsect3">
<a name="g-test-initialized.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> has been called.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-quick"></a><h3>g_test_quick</h3>
<pre class="programlisting">#define g_test_quick()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in quick mode.
Exactly one of <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick"><code class="function">g_test_quick()</code></a> and <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a> is active in any run;
there is no "medium speed".</p>
<div class="refsect3">
<a name="g-test-quick.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in quick mode</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-slow"></a><h3>g_test_slow</h3>
<pre class="programlisting">#define g_test_slow()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in slow mode.
Exactly one of <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick"><code class="function">g_test_quick()</code></a> and <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a> is active in any run;
there is no "medium speed".</p>
<div class="refsect3">
<a name="g-test-slow.returns"></a><h4>Returns</h4>
<p> the opposite of <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick"><code class="function">g_test_quick()</code></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-thorough"></a><h3>g_test_thorough</h3>
<pre class="programlisting">#define g_test_thorough()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in thorough mode, equivalent to
<a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a>.</p>
<div class="refsect3">
<a name="g-test-thorough.returns"></a><h4>Returns</h4>
<p> the same thing as <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-perf"></a><h3>g_test_perf</h3>
<pre class="programlisting">#define g_test_perf()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in performance mode.</p>
<div class="refsect3">
<a name="g-test-perf.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in performance mode</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-verbose"></a><h3>g_test_verbose</h3>
<pre class="programlisting">#define g_test_verbose()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in verbose mode.
The default is neither <a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose"><code class="function">g_test_verbose()</code></a> nor <a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet"><code class="function">g_test_quiet()</code></a>.</p>
<div class="refsect3">
<a name="g-test-verbose.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in verbose mode</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-undefined"></a><h3>g_test_undefined</h3>
<pre class="programlisting">#define g_test_undefined()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests may provoke assertions and other formally-undefined
behaviour, to verify that appropriate warnings are given. It might, in some
cases, be useful to turn this off if running tests under valgrind.</p>
<div class="refsect3">
<a name="g-test-undefined.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests may provoke programming errors</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-quiet"></a><h3>g_test_quiet</h3>
<pre class="programlisting">#define g_test_quiet()</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in quiet mode.
The default is neither <a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose"><code class="function">g_test_verbose()</code></a> nor <a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet"><code class="function">g_test_quiet()</code></a>.</p>
<div class="refsect3">
<a name="g-test-quiet.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in quiet mode</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-subprocess"></a><h3>g_test_subprocess ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_test_subprocess (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> (after <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> has been called) if the test
program is running under <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<div class="refsect3">
<a name="g-test-subprocess.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the test program is running under
<a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-run"></a><h3>g_test_run ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span>
g_test_run (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Runs all tests under the toplevel suite which can be retrieved
with <a class="link" href="glib-Testing.html#g-test-get-root" title="g_test_get_root ()"><code class="function">g_test_get_root()</code></a>. Similar to <a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()"><code class="function">g_test_run_suite()</code></a>, the test
cases to be run are filtered according to test path arguments
(<code class="literal">-p testpath</code>) as parsed by <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>. <a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()"><code class="function">g_test_run_suite()</code></a>
or <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()"><code class="function">g_test_run()</code></a> may only be called once in a program.</p>
<p>In general, the tests and sub-suites within each suite are run in
the order in which they are defined. However, note that prior to
GLib 2.36, there was a bug in the <code class="literal">g_test_add_*</code>
functions which caused them to create multiple suites with the same
name, meaning that if you created tests "/foo/simple",
"/bar/simple", and "/foo/using-bar" in that order, they would get
run in that order (since <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()"><code class="function">g_test_run()</code></a> would run the first "/foo"
suite, then the "/bar" suite, then the second "/foo" suite). As of
2.36, this bug is fixed, and adding the tests in that order would
result in a running order of "/foo/simple", "/foo/using-bar",
"/bar/simple". If this new ordering is sub-optimal (because it puts
more-complicated tests before simpler ones, making it harder to
figure out exactly what has failed), you can fix it by changing the
test paths to group tests by suite in a way that will result in the
desired running order. Eg, "/simple/foo", "/simple/bar",
"/complex/foo-using-bar".</p>
<p>However, you should never make the actual result of a test depend
on the order that tests are run in. If you need to ensure that some
particular code runs before or after a given test case, use
<a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()"><code class="function">g_test_add()</code></a>, which lets you specify setup and teardown functions.</p>
<p>If all tests are skipped, this function will return 0 if
producing TAP output, or 77 (treated as "skip test" by Automake) otherwise.</p>
<div class="refsect3">
<a name="g-test-run.returns"></a><h4>Returns</h4>
<p> 0 on success, 1 on failure (assuming it returns at all),
0 or 77 if all tests were skipped with <a class="link" href="glib-Testing.html#g-test-skip" title="g_test_skip ()"><code class="function">g_test_skip()</code></a></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GTestFunc"></a><h3>GTestFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
<span class="c_punctuation">(</span>*GTestFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>The type used for test case functions.</p>
<p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add-func"></a><h3>g_test_add_func ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_add_func (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFunc" title="GTestFunc ()"><span class="type">GTestFunc</span></a> test_func</code></em>);</pre>
<p>Create a new test case, similar to <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a>. However
the test is assumed to use no fixture, and test suites are automatically
created on the fly and added to the root fixture, based on the
slash-separated portions of <em class="parameter"><code>testpath</code></em>
.</p>
<p>If <em class="parameter"><code>testpath</code></em>
includes the component "subprocess" anywhere in it,
the test will be skipped by default, and only run if explicitly
required via the <code class="literal">-p</code> command-line option or <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<div class="refsect3">
<a name="g-test-add-func.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>testpath</p></td>
<td class="parameter_description"><p>/-separated test case path name for the test.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_func</p></td>
<td class="parameter_description"><p> The test function to invoke for this test. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GTestDataFunc"></a><h3>GTestDataFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
<span class="c_punctuation">(</span>*GTestDataFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> user_data</code></em>);</pre>
<p>The type used for test case functions that take an extra pointer
argument.</p>
<div class="refsect3">
<a name="GTestDataFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>the data provided when registering the test</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add-data-func"></a><h3>g_test_add_data_func ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_add_data_func (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> test_data</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()"><span class="type">GTestDataFunc</span></a> test_func</code></em>);</pre>
<p>Create a new test case, similar to <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a>. However
the test is assumed to use no fixture, and test suites are automatically
created on the fly and added to the root fixture, based on the
slash-separated portions of <em class="parameter"><code>testpath</code></em>
. The <em class="parameter"><code>test_data</code></em>
argument
will be passed as first argument to <em class="parameter"><code>test_func</code></em>
.</p>
<p>If <em class="parameter"><code>testpath</code></em>
includes the component "subprocess" anywhere in it,
the test will be skipped by default, and only run if explicitly
required via the <code class="literal">-p</code> command-line option or <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<div class="refsect3">
<a name="g-test-add-data-func.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>testpath</p></td>
<td class="parameter_description"><p>/-separated test case path name for the test.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_data</p></td>
<td class="parameter_description"><p>Test data argument for the test function.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_func</p></td>
<td class="parameter_description"><p> The test function to invoke for this test. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add-data-func-full"></a><h3>g_test_add_data_func_full ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_add_data_func_full (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> test_data</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()"><span class="type">GTestDataFunc</span></a> test_func</code></em>,
<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> data_free_func</code></em>);</pre>
<p>Create a new test case, as with <a class="link" href="glib-Testing.html#g-test-add-data-func" title="g_test_add_data_func ()"><code class="function">g_test_add_data_func()</code></a>, but freeing
<em class="parameter"><code>test_data</code></em>
after the test run is complete.</p>
<div class="refsect3">
<a name="g-test-add-data-func-full.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>testpath</p></td>
<td class="parameter_description"><p>/-separated test case path name for the test.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_data</p></td>
<td class="parameter_description"><p>Test data argument for the test function.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_func</p></td>
<td class="parameter_description"><p>The test function to invoke for this test.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data_free_func</p></td>
<td class="parameter_description"><p><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>test_data</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-34.html#api-index-2.34">2.34</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add"></a><h3>g_test_add()</h3>
<pre class="programlisting">#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown)</pre>
<p>Hook up a new test case at <em class="parameter"><code>testpath</code></em>
, similar to <a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()"><code class="function">g_test_add_func()</code></a>.
A fixture data structure with setup and teardown functions may be provided,
similar to <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a>.</p>
<p>g_test_add() is implemented as a macro, so that the <code class="function">fsetup()</code>, <code class="function">ftest()</code> and
<code class="function">fteardown()</code> callbacks can expect a <em class="parameter"><code>Fixture</code></em>
pointer as their first argument
in a type safe manner. They otherwise have type <a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a>.</p>
<div class="refsect3">
<a name="g-test-add.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>testpath</p></td>
<td class="parameter_description"><p>The test path for a new test case.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>Fixture</p></td>
<td class="parameter_description"><p>The type of a fixture data structure.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>tdata</p></td>
<td class="parameter_description"><p>Data argument for the test functions.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>fsetup</p></td>
<td class="parameter_description"><p>The function to set up the fixture data.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>ftest</p></td>
<td class="parameter_description"><p>The actual test function.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>fteardown</p></td>
<td class="parameter_description"><p>The function to tear down the fixture data.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-build-filename"></a><h3>g_test_build_filename ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_test_build_filename (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *first_path</code></em>,
<em class="parameter"><code>...</code></em>);</pre>
<p>Creates the pathname to a data file that is required for a test.</p>
<p>This function is conceptually similar to <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-build-filename" title="g_build_filename ()"><code class="function">g_build_filename()</code></a> except
that the first argument has been replaced with a <a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a>
argument.</p>
<p>The data file should either have been distributed with the module
containing the test (<a class="link" href="glib-Testing.html#G-TEST-DIST:CAPS"><code class="literal">G_TEST_DIST</code></a>) or built as part of the build
system of that module (<a class="link" href="glib-Testing.html#G-TEST-BUILT:CAPS"><code class="literal">G_TEST_BUILT</code></a>).</p>
<p>In order for this function to work in srcdir != builddir situations,
the G_TEST_SRCDIR and G_TEST_BUILDDIR environment variables need to
have been defined. As of 2.38, this is done by the glib.mk
included in GLib. Please ensure that your copy is up to date before
using this function.</p>
<p>In case neither variable is set, this function will fall back to
using the dirname portion of argv[0], possibly removing ".libs".
This allows for casual running of tests directly from the commandline
in the srcdir == builddir case and should also support running of
installed tests, assuming the data files have been installed in the
same relative path as the test binary.</p>
<div class="refsect3">
<a name="g-test-build-filename.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>file_type</p></td>
<td class="parameter_description"><p>the type of file (built vs. distributed)</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>first_path</p></td>
<td class="parameter_description"><p>the first segment of the pathname</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p><a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated additional path segments</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-build-filename.returns"></a><h4>Returns</h4>
<p> the path of the file, to be freed using <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-get-filename"></a><h3>g_test_get_filename ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_test_get_filename (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *first_path</code></em>,
<em class="parameter"><code>...</code></em>);</pre>
<p>Gets the pathname to a data file that is required for a test.</p>
<p>This is the same as <a class="link" href="glib-Testing.html#g-test-build-filename" title="g_test_build_filename ()"><code class="function">g_test_build_filename()</code></a> with two differences.
The first difference is that must only use this function from within
a testcase function. The second difference is that you need not free
the return value -- it will be automatically freed when the testcase
finishes running.</p>
<p>It is safe to use this function from a thread inside of a testcase
but you must ensure that all such uses occur before the main testcase
function returns (ie: it is best to ensure that all threads have been
joined).</p>
<div class="refsect3">
<a name="g-test-get-filename.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>file_type</p></td>
<td class="parameter_description"><p>the type of file (built vs. distributed)</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>first_path</p></td>
<td class="parameter_description"><p>the first segment of the pathname</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p><a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated additional path segments</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-get-filename.returns"></a><h4>Returns</h4>
<p> the path, automatically freed at the end of the testcase</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-get-dir"></a><h3>g_test_get_dir ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_test_get_dir (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>);</pre>
<p>Gets the pathname of the directory containing test files of the type
specified by <em class="parameter"><code>file_type</code></em>
.</p>
<p>This is approximately the same as calling g_test_build_filename("."),
but you don't need to free the return value.</p>
<div class="refsect3">
<a name="g-test-get-dir.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>file_type</p></td>
<td class="parameter_description"><p>the type of file (built vs. distributed)</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-get-dir.returns"></a><h4>Returns</h4>
<p> the path of the directory, owned by GLib. </p>
<p><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> filename]</span></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-fail"></a><h3>g_test_fail ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_fail (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Indicates that a test failed. This function can be called
multiple times from the same test. You can use this function
if your test failed in a recoverable way.</p>
<p>Do not use this function if the failure of a test could cause
other tests to malfunction.</p>
<p>Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.</p>
<p>If not called from inside a test, this function does nothing.</p>
<p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-skip"></a><h3>g_test_skip ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_skip (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *msg</code></em>);</pre>
<p>Indicates that a test was skipped.</p>
<p>Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.</p>
<p>If not called from inside a test, this function does nothing.</p>
<div class="refsect3">
<a name="g-test-skip.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>msg</p></td>
<td class="parameter_description"><p> explanation. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-incomplete"></a><h3>g_test_incomplete ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_incomplete (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *msg</code></em>);</pre>
<p>Indicates that a test failed because of some incomplete
functionality. This function can be called multiple times
from the same test.</p>
<p>Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.</p>
<p>If not called from inside a test, this function does nothing.</p>
<div class="refsect3">
<a name="g-test-incomplete.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>msg</p></td>
<td class="parameter_description"><p> explanation. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-failed"></a><h3>g_test_failed ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_test_failed (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Returns whether a test has already failed. This will
be the case when <a class="link" href="glib-Testing.html#g-test-fail" title="g_test_fail ()"><code class="function">g_test_fail()</code></a>, <a class="link" href="glib-Testing.html#g-test-incomplete" title="g_test_incomplete ()"><code class="function">g_test_incomplete()</code></a>
or <a class="link" href="glib-Testing.html#g-test-skip" title="g_test_skip ()"><code class="function">g_test_skip()</code></a> have been called, but also if an
assertion has failed.</p>
<p>This can be useful to return early from a test if
continuing after a failed assertion might be harmful.</p>
<p>The return value of this function is only meaningful
if it is called from inside a test function.</p>
<div class="refsect3">
<a name="g-test-failed.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the test has failed</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-message"></a><h3>g_test_message ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_message (<em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
<em class="parameter"><code>...</code></em>);</pre>
<p>Add a message to the test report.</p>
<div class="refsect3">
<a name="g-test-message.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>format</p></td>
<td class="parameter_description"><p>the format string</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>printf-like arguments to <em class="parameter"><code>format</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-bug-base"></a><h3>g_test_bug_base ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_bug_base (<em class="parameter"><code>const <span class="type">char</span> *uri_pattern</code></em>);</pre>
<p>Specify the base URI for bug reports.</p>
<p>The base URI is used to construct bug report messages for
<a class="link" href="glib-Testing.html#g-test-message" title="g_test_message ()"><code class="function">g_test_message()</code></a> when <a class="link" href="glib-Testing.html#g-test-bug" title="g_test_bug ()"><code class="function">g_test_bug()</code></a> is called.
Calling this function outside of a test case sets the
default base URI for all test cases. Calling it from within
a test case changes the base URI for the scope of the test
case only.
Bug URIs are constructed by appending a bug specific URI
portion to <em class="parameter"><code>uri_pattern</code></em>
, or by replacing the special string
'%s' within <em class="parameter"><code>uri_pattern</code></em>
if that is present.</p>
<div class="refsect3">
<a name="g-test-bug-base.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>uri_pattern</p></td>
<td class="parameter_description"><p>the base pattern for bug URIs</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-bug"></a><h3>g_test_bug ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_bug (<em class="parameter"><code>const <span class="type">char</span> *bug_uri_snippet</code></em>);</pre>
<p>This function adds a message to test reports that
associates a bug URI with a test case.
Bug URIs are constructed from a base URI set with <a class="link" href="glib-Testing.html#g-test-bug-base" title="g_test_bug_base ()"><code class="function">g_test_bug_base()</code></a>
and <em class="parameter"><code>bug_uri_snippet</code></em>
.</p>
<div class="refsect3">
<a name="g-test-bug.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>bug_uri_snippet</p></td>
<td class="parameter_description"><p>Bug specific bug tracker URI portion.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GTestLogFatalFunc"></a><h3>GTestLogFatalFunc ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
<span class="c_punctuation">(</span>*GTestLogFatalFunc<span class="c_punctuation">)</span> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
<em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Specifies the prototype of fatal log handler functions.</p>
<div class="refsect3">
<a name="GTestLogFatalFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>log_domain</p></td>
<td class="parameter_description"><p>the log domain of the message</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>log_level</p></td>
<td class="parameter_description"><p>the log level of the message (including the fatal and recursion flags)</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>message</p></td>
<td class="parameter_description"><p>the message to process</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data, set in <a class="link" href="glib-Testing.html#g-test-log-set-fatal-handler" title="g_test_log_set_fatal_handler ()"><code class="function">g_test_log_set_fatal_handler()</code></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="GTestLogFatalFunc.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the program should abort, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> otherwise</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-log-set-fatal-handler"></a><h3>g_test_log_set_fatal_handler ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_log_set_fatal_handler (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestLogFatalFunc" title="GTestLogFatalFunc ()"><span class="type">GTestLogFatalFunc</span></a> log_func</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Installs a non-error fatal log handler which can be
used to decide whether log messages which are counted
as fatal abort the program.</p>
<p>The use case here is that you are running a test case
that depends on particular libraries or circumstances
and cannot prevent certain known critical or warning
messages. So you install a handler that compares the
domain and message to precisely not abort in such a case.</p>
<p>Note that the handler is reset at the beginning of
any test case, so you have to set it inside each test
function which needs the special behavior.</p>
<p>This handler has no effect on g_error messages.</p>
<p>This handler also has no effect on structured log messages (using
<a class="link" href="glib-Message-Logging.html#g-log-structured" title="g_log_structured ()"><code class="function">g_log_structured()</code></a> or <a class="link" href="glib-Message-Logging.html#g-log-structured-array" title="g_log_structured_array ()"><code class="function">g_log_structured_array()</code></a>). To change the fatal
behaviour for specific log messages, programs must install a custom log
writer function using <a class="link" href="glib-Message-Logging.html#g-log-set-writer-func" title="g_log_set_writer_func ()"><code class="function">g_log_set_writer_func()</code></a>.</p>
<div class="refsect3">
<a name="g-test-log-set-fatal-handler.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>log_func</p></td>
<td class="parameter_description"><p>the log handler function.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>data passed to the log handler.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-timer-start"></a><h3>g_test_timer_start ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_timer_start (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Start a timing test. Call <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()"><code class="function">g_test_timer_elapsed()</code></a> when the task is supposed
to be done. Call this function again to restart the timer.</p>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-timer-elapsed"></a><h3>g_test_timer_elapsed ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>
g_test_timer_elapsed (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Get the time since the last start of the timer with <a class="link" href="glib-Testing.html#g-test-timer-start" title="g_test_timer_start ()"><code class="function">g_test_timer_start()</code></a>.</p>
<div class="refsect3">
<a name="g-test-timer-elapsed.returns"></a><h4>Returns</h4>
<p> the time since the last start of the timer, as a double</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-timer-last"></a><h3>g_test_timer_last ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>
g_test_timer_last (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Report the last result of <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()"><code class="function">g_test_timer_elapsed()</code></a>.</p>
<div class="refsect3">
<a name="g-test-timer-last.returns"></a><h4>Returns</h4>
<p> the last result of <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()"><code class="function">g_test_timer_elapsed()</code></a>, as a double</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-queue-free"></a><h3>g_test_queue_free ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_queue_free (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> gfree_pointer</code></em>);</pre>
<p>Enqueue a pointer to be released with <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> during the next
teardown phase. This is equivalent to calling <a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()"><code class="function">g_test_queue_destroy()</code></a>
with a destroy callback of <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>.</p>
<div class="refsect3">
<a name="g-test-queue-free.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>gfree_pointer</p></td>
<td class="parameter_description"><p>the pointer to be stored.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-queue-destroy"></a><h3>g_test_queue_destroy ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_queue_destroy (<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> destroy_func</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> destroy_data</code></em>);</pre>
<p>This function enqueus a callback <em class="parameter"><code>destroy_func</code></em>
to be executed
during the next test case teardown phase. This is most useful
to auto destruct allocted test resources at the end of a test run.
Resources are released in reverse queue order, that means enqueueing
callback A before callback B will cause <code class="function">B()</code> to be called before
<code class="function">A()</code> during teardown.</p>
<div class="refsect3">
<a name="g-test-queue-destroy.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>destroy_func</p></td>
<td class="parameter_description"><p>Destroy callback for teardown phase.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>destroy_data</p></td>
<td class="parameter_description"><p>Destroy callback data.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-queue-unref"></a><h3>g_test_queue_unref()</h3>
<pre class="programlisting">#define g_test_queue_unref(gobject)</pre>
<p>Enqueue an object to be released with <a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a> during
the next teardown phase. This is equivalent to calling
<a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()"><code class="function">g_test_queue_destroy()</code></a> with a destroy callback of <a href="https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>.</p>
<div class="refsect3">
<a name="g-test-queue-unref.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>gobject</p></td>
<td class="parameter_description"><p>the object to unref</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-expect-message"></a><h3>g_test_expect_message ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_expect_message (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
<em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *pattern</code></em>);</pre>
<p>Indicates that a message with the given <em class="parameter"><code>log_domain</code></em>
and <em class="parameter"><code>log_level</code></em>
,
with text matching <em class="parameter"><code>pattern</code></em>
, is expected to be logged. When this
message is logged, it will not be printed, and the test case will
not abort.</p>
<p>Use <a class="link" href="glib-Testing.html#g-test-assert-expected-messages" title="g_test_assert_expected_messages"><code class="function">g_test_assert_expected_messages()</code></a> to assert that all
previously-expected messages have been seen and suppressed.</p>
<p>You can call this multiple times in a row, if multiple messages are
expected as a result of a single call. (The messages must appear in
the same order as the calls to <a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()"><code class="function">g_test_expect_message()</code></a>.)</p>
<p>For example:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="comment">// g_main_context_push_thread_default() should fail if the</span>
<span class="comment">// context is already owned by another thread.</span>
<span class="function"><a href="glib-Testing.html#g-test-expect-message">g_test_expect_message</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Message-Logging.html#G-LOG-DOMAIN:CAPS">G_LOG_DOMAIN</a></span><span class="symbol">,</span>
<span class="normal"> <a href="glib-Message-Logging.html#G-LOG-LEVEL-CRITICAL:CAPS">G_LOG_LEVEL_CRITICAL</a></span><span class="symbol">,</span>
<span class="normal"> </span><span class="string">"assertion*acquired_context*failed"</span><span class="symbol">);</span>
<span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default">g_main_context_push_thread_default</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">bad_context</span><span class="symbol">);</span>
<span class="function"><a href="glib-Testing.html#g-test-assert-expected-messages">g_test_assert_expected_messages</a></span><span class="normal"> </span><span class="symbol">();</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
<p>Note that you cannot use this to test <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a> messages, since
<a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a> intentionally never returns even if the program doesn't
abort; use <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> in this case.</p>
<p>If messages at <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-DEBUG:CAPS"><code class="literal">G_LOG_LEVEL_DEBUG</code></a> are emitted, but not explicitly
expected via <a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()"><code class="function">g_test_expect_message()</code></a> then they will be ignored.</p>
<div class="refsect3">
<a name="g-test-expect-message.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>log_domain</p></td>
<td class="parameter_description"><p> the log domain of the message. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>log_level</p></td>
<td class="parameter_description"><p>the log level of the message</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>pattern</p></td>
<td class="parameter_description"><p>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-34.html#api-index-2.34">2.34</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-assert-expected-messages"></a><h3>g_test_assert_expected_messages</h3>
<pre class="programlisting">#define g_test_assert_expected_messages()</pre>
<p>Asserts that all messages previously indicated via
<a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()"><code class="function">g_test_expect_message()</code></a> have been seen and suppressed.</p>
<p>If messages at <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-DEBUG:CAPS"><code class="literal">G_LOG_LEVEL_DEBUG</code></a> are emitted, but not explicitly
expected via <a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()"><code class="function">g_test_expect_message()</code></a> then they will be ignored.</p>
<p class="since">Since: <a class="link" href="api-index-2-34.html#api-index-2.34">2.34</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-subprocess"></a><h3>g_test_trap_subprocess ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_trap_subprocess (<em class="parameter"><code>const <span class="type">char</span> *test_path</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> usec_timeout</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags"><span class="type">GTestSubprocessFlags</span></a> test_flags</code></em>);</pre>
<p>Respawns the test program to run only <em class="parameter"><code>test_path</code></em>
in a subprocess.
This can be used for a test case that might not return, or that
might abort.</p>
<p>If <em class="parameter"><code>test_path</code></em>
is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> then the same test is re-run in a subprocess.
You can use <a class="link" href="glib-Testing.html#g-test-subprocess" title="g_test_subprocess ()"><code class="function">g_test_subprocess()</code></a> to determine whether the test is in
a subprocess or not.</p>
<p><em class="parameter"><code>test_path</code></em>
can also be the name of the parent test, followed by
"<code class="literal">/subprocess/</code>" and then a name for the specific subtest (or just
ending with "<code class="literal">/subprocess</code>" if the test only has one child test);
tests with names of this form will automatically be skipped in the
parent process.</p>
<p>If <em class="parameter"><code>usec_timeout</code></em>
is non-0, the test subprocess is aborted and
considered failing if its run time exceeds it.</p>
<p>The subprocess behavior can be configured with the
<a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags"><span class="type">GTestSubprocessFlags</span></a> flags.</p>
<p>You can use methods such as <a class="link" href="glib-Testing.html#g-test-trap-assert-passed" title="g_test_trap_assert_passed"><code class="function">g_test_trap_assert_passed()</code></a>,
<a class="link" href="glib-Testing.html#g-test-trap-assert-failed" title="g_test_trap_assert_failed"><code class="function">g_test_trap_assert_failed()</code></a>, and <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a> to
check the results of the subprocess. (But note that
<a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()"><code class="function">g_test_trap_assert_stdout()</code></a> and <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a>
cannot be used if <em class="parameter"><code>test_flags</code></em>
specifies that the child should
inherit the parent stdout/stderr.) </p>
<p>If your <code class="literal"><code class="function">main()</code></code> needs to behave differently in
the subprocess, you can call <a class="link" href="glib-Testing.html#g-test-subprocess" title="g_test_subprocess ()"><code class="function">g_test_subprocess()</code></a> (after calling
<a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>) to see whether you are in a subprocess.</p>
<p>The following example tests that calling
<code class="literal">my_object_new(1000000)</code> will abort with an error
message.</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_create_large_object</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Testing.html#g-test-subprocess">g_test_subprocess</a></span><span class="normal"> </span><span class="symbol">())</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="function">my_object_new</span><span class="normal"> </span><span class="symbol">(</span><span class="number">1000000</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">return</span><span class="symbol">;</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="normal"> </span><span class="comment">// Reruns this same test in a subprocess</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-trap-subprocess">g_test_trap_subprocess</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-failed">g_test_trap_assert_failed</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-stderr">g_test_trap_assert_stderr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"*ERROR*too large*"</span><span class="symbol">);</span>
<span class="cbracket">}</span>
<span class="type">int</span>
<span class="function">main</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> argc</span><span class="symbol">,</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">**</span><span class="normal">argv</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-init">g_test_init</a></span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">argc</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&amp;</span><span class="normal">argv</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-add-func">g_test_add_func</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/myobject/create_large_object"</span><span class="symbol">,</span>
<span class="normal"> test_create_large_object</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-run">g_test_run</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
<div class="refsect3">
<a name="g-test-trap-subprocess.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>test_path</p></td>
<td class="parameter_description"><p> Test to run in a subprocess. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>usec_timeout</p></td>
<td class="parameter_description"><p>Timeout for the subprocess test in micro seconds.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_flags</p></td>
<td class="parameter_description"><p>Flags to modify subprocess behaviour.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-has-passed"></a><h3>g_test_trap_has_passed ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_test_trap_has_passed (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Check the result of the last <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> call.</p>
<div class="refsect3">
<a name="g-test-trap-has-passed.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the last test subprocess terminated successfully.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-reached-timeout"></a><h3>g_test_trap_reached_timeout ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_test_trap_reached_timeout (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Check the result of the last <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> call.</p>
<div class="refsect3">
<a name="g-test-trap-reached-timeout.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the last test subprocess got killed due to a timeout.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-passed"></a><h3>g_test_trap_assert_passed</h3>
<pre class="programlisting">#define g_test_trap_assert_passed()</pre>
<p>Assert that the last test subprocess passed.
See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-failed"></a><h3>g_test_trap_assert_failed</h3>
<pre class="programlisting">#define g_test_trap_assert_failed()</pre>
<p>Assert that the last test subprocess failed.
See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<p>This is sometimes used to test situations that are formally considered to
be undefined behaviour, like inputs that fail a <a class="link" href="glib-Warnings-and-Assertions.html#g-return-if-fail" title="g_return_if_fail()"><code class="function">g_return_if_fail()</code></a>
check. In these situations you should skip the entire test, including the
call to <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>, unless <a class="link" href="glib-Testing.html#g-test-undefined" title="g_test_undefined"><code class="function">g_test_undefined()</code></a> returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>
to indicate that undefined behaviour may be tested.</p>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stdout"></a><h3>g_test_trap_assert_stdout()</h3>
<pre class="programlisting">#define g_test_trap_assert_stdout(soutpattern)</pre>
<p>Assert that the stdout output of the last test subprocess matches
<em class="parameter"><code>soutpattern</code></em>
. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<div class="refsect3">
<a name="g-test-trap-assert-stdout.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>soutpattern</p></td>
<td class="parameter_description"><p>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stdout-unmatched"></a><h3>g_test_trap_assert_stdout_unmatched()</h3>
<pre class="programlisting">#define g_test_trap_assert_stdout_unmatched(soutpattern)</pre>
<p>Assert that the stdout output of the last test subprocess
does not match <em class="parameter"><code>soutpattern</code></em>
. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<div class="refsect3">
<a name="g-test-trap-assert-stdout-unmatched.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>soutpattern</p></td>
<td class="parameter_description"><p>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stderr"></a><h3>g_test_trap_assert_stderr()</h3>
<pre class="programlisting">#define g_test_trap_assert_stderr(serrpattern)</pre>
<p>Assert that the stderr output of the last test subprocess
matches <em class="parameter"><code>serrpattern</code></em>
. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<p>This is sometimes used to test situations that are formally
considered to be undefined behaviour, like code that hits a
<a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a> or <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a>. In these situations you should skip the
entire test, including the call to <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>, unless
<a class="link" href="glib-Testing.html#g-test-undefined" title="g_test_undefined"><code class="function">g_test_undefined()</code></a> returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> to indicate that undefined
behaviour may be tested.</p>
<div class="refsect3">
<a name="g-test-trap-assert-stderr.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>serrpattern</p></td>
<td class="parameter_description"><p>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stderr-unmatched"></a><h3>g_test_trap_assert_stderr_unmatched()</h3>
<pre class="programlisting">#define g_test_trap_assert_stderr_unmatched(serrpattern)</pre>
<p>Assert that the stderr output of the last test subprocess
does not match <em class="parameter"><code>serrpattern</code></em>
. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</p>
<div class="refsect3">
<a name="g-test-trap-assert-stderr-unmatched.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>serrpattern</p></td>
<td class="parameter_description"><p>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-fork"></a><h3>g_test_trap_fork ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
g_test_trap_fork (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> usec_timeout</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> test_trap_flags</code></em>);</pre>
<div class="warning">
<p><code class="literal">g_test_trap_fork</code> is deprecated and should not be used in newly-written code.</p>
<p>This function is implemented only on Unix platforms,
and is not always reliable due to problems inherent in
fork-without-exec. Use <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> instead.</p>
</div>
<p>Fork the current test program to execute a test case that might
not return or that might abort.</p>
<p>If <em class="parameter"><code>usec_timeout</code></em>
is non-0, the forked test case is aborted and
considered failing if its run time exceeds it.</p>
<p>The forking behavior can be configured with the <a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> flags.</p>
<p>In the following example, the test code forks, the forked child
process produces some sample output and exits successfully.
The forking parent process then asserts successful child program
termination and validates child program outputs.</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_fork_patterns</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Testing.html#g-test-trap-fork">g_test_trap_fork</a></span><span class="normal"> </span><span class="symbol">(</span><span class="number">0</span><span class="symbol">,</span><span class="normal"> <a href="glib-Testing.html#G-TEST-TRAP-SILENCE-STDOUT:CAPS">G_TEST_TRAP_SILENCE_STDOUT</a> </span><span class="symbol">|</span><span class="normal"> <a href="glib-Testing.html#G-TEST-TRAP-SILENCE-STDERR:CAPS">G_TEST_TRAP_SILENCE_STDERR</a></span><span class="symbol">))</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"some stdout text: somagic17</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-printerr">g_printerr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"some stderr text: semagic43</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function">exit</span><span class="normal"> </span><span class="symbol">(</span><span class="number">0</span><span class="symbol">);</span><span class="normal"> </span><span class="comment">// successful test run</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-passed">g_test_trap_assert_passed</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-stdout">g_test_trap_assert_stdout</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"*somagic17*"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-stderr">g_test_trap_assert_stderr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"*semagic43*"</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
<div class="refsect3">
<a name="g-test-trap-fork.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>usec_timeout</p></td>
<td class="parameter_description"><p>Timeout for the forked test in micro seconds.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_trap_flags</p></td>
<td class="parameter_description"><p>Flags to modify forking behaviour.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-trap-fork.returns"></a><h4>Returns</h4>
<p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> for the forked child and <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> for the executing parent process.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-bit"></a><h3>g_test_rand_bit</h3>
<pre class="programlisting">#define g_test_rand_bit()</pre>
<p>Get a reproducible random bit (0 or 1), see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a>
for details on test case random numbers.</p>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-int"></a><h3>g_test_rand_int ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>
g_test_rand_int (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Get a reproducible random integer number.</p>
<p>The random numbers generated by the g_test_rand_*() family of functions
change with every new test program start, unless the --seed option is
given when starting test programs.</p>
<p>For individual test cases however, the random number generator is
reseeded, to avoid dependencies between tests and to make --seed
effective for all test cases.</p>
<div class="refsect3">
<a name="g-test-rand-int.returns"></a><h4>Returns</h4>
<p> a random number from the seeded random number generator.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-int-range"></a><h3>g_test_rand_int_range ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>
g_test_rand_int_range (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> begin</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> end</code></em>);</pre>
<p>Get a reproducible random integer number out of a specified range,
see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a> for details on test case random numbers.</p>
<div class="refsect3">
<a name="g-test-rand-int-range.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>begin</p></td>
<td class="parameter_description"><p>the minimum value returned by this function</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>end</p></td>
<td class="parameter_description"><p>the smallest value not to be returned by this function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-rand-int-range.returns"></a><h4>Returns</h4>
<p> a number with <em class="parameter"><code>begin</code></em>
&lt;= number &lt; <em class="parameter"><code>end</code></em>
.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-double"></a><h3>g_test_rand_double ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>
g_test_rand_double (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Get a reproducible random floating point number,
see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a> for details on test case random numbers.</p>
<div class="refsect3">
<a name="g-test-rand-double.returns"></a><h4>Returns</h4>
<p> a random number from the seeded random number generator.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-double-range"></a><h3>g_test_rand_double_range ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>
g_test_rand_double_range (<em class="parameter"><code><span class="type">double</span> range_start</code></em>,
<em class="parameter"><code><span class="type">double</span> range_end</code></em>);</pre>
<p>Get a reproducible random floating pointer number out of a specified range,
see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a> for details on test case random numbers.</p>
<div class="refsect3">
<a name="g-test-rand-double-range.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>range_start</p></td>
<td class="parameter_description"><p>the minimum value returned by this function</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>range_end</p></td>
<td class="parameter_description"><p>the minimum value not returned by this function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-rand-double-range.returns"></a><h4>Returns</h4>
<p> a number with <em class="parameter"><code>range_start</code></em>
&lt;= number &lt; <em class="parameter"><code>range_end</code></em>
.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert"></a><h3>g_assert()</h3>
<pre class="programlisting">#define g_assert(expr)</pre>
<p>Debugging macro to terminate the application if the assertion
fails. If the assertion fails (i.e. the expression is not true),
an error message is logged and the application is terminated.</p>
<p>The macro can be turned off in final releases of code by defining
<code class="literal">G_DISABLE_ASSERT</code> when compiling the application.</p>
<div class="refsect3">
<a name="g-assert.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>expr</p></td>
<td class="parameter_description"><p>the expression to check</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-not-reached"></a><h3>g_assert_not_reached</h3>
<pre class="programlisting">#define g_assert_not_reached()</pre>
<p>Debugging macro to terminate the application if it is ever
reached. If it is reached, an error message is logged and the
application is terminated.</p>
<p>The macro can be turned off in final releases of code by defining
<code class="literal">G_DISABLE_ASSERT</code> when compiling the application.</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpstr"></a><h3>g_assert_cmpstr()</h3>
<pre class="programlisting">#define g_assert_cmpstr(s1, cmp, s2)</pre>
<p>Debugging macro to compare two strings. If the comparison fails,
an error message is logged and the application is either terminated
or the testcase marked as failed.
The strings are compared using <a class="link" href="glib-String-Utility-Functions.html#g-strcmp0" title="g_strcmp0 ()"><code class="function">g_strcmp0()</code></a>.</p>
<p>The effect of <code class="literal">g_assert_cmpstr (s1, op, s2)</code> is
the same as <code class="literal">g_assert_true (g_strcmp0 (s1, s2) op 0)</code>.
The advantage of this macro is that it can produce a message that
includes the actual values of <em class="parameter"><code>s1</code></em>
and <em class="parameter"><code>s2</code></em>
.</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Testing.html#g-assert-cmpstr">g_assert_cmpstr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">mystring</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">==,</span><span class="normal"> </span><span class="string">"fubar"</span><span class="symbol">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
<div class="refsect3">
<a name="g-assert-cmpstr.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>s1</p></td>
<td class="parameter_description"><p>a string (may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>)</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>cmp</p></td>
<td class="parameter_description"><p>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>s2</p></td>
<td class="parameter_description"><p>another string (may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>)</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpint"></a><h3>g_assert_cmpint()</h3>
<pre class="programlisting">#define g_assert_cmpint(n1, cmp, n2)</pre>
<p>Debugging macro to compare two integers.</p>
<p>The effect of <code class="literal">g_assert_cmpint (n1, op, n2)</code> is
the same as <code class="literal">g_assert_true (n1 op n2)</code>. The advantage
of this macro is that it can produce a message that includes the
actual values of <em class="parameter"><code>n1</code></em>
and <em class="parameter"><code>n2</code></em>
.</p>
<div class="refsect3">
<a name="g-assert-cmpint.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>n1</p></td>
<td class="parameter_description"><p>an integer</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>cmp</p></td>
<td class="parameter_description"><p>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n2</p></td>
<td class="parameter_description"><p>another integer</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpuint"></a><h3>g_assert_cmpuint()</h3>
<pre class="programlisting">#define g_assert_cmpuint(n1, cmp, n2)</pre>
<p>Debugging macro to compare two unsigned integers.</p>
<p>The effect of <code class="literal">g_assert_cmpuint (n1, op, n2)</code> is
the same as <code class="literal">g_assert_true (n1 op n2)</code>. The advantage
of this macro is that it can produce a message that includes the
actual values of <em class="parameter"><code>n1</code></em>
and <em class="parameter"><code>n2</code></em>
.</p>
<div class="refsect3">
<a name="g-assert-cmpuint.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>n1</p></td>
<td class="parameter_description"><p>an unsigned integer</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>cmp</p></td>
<td class="parameter_description"><p>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n2</p></td>
<td class="parameter_description"><p>another unsigned integer</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmphex"></a><h3>g_assert_cmphex()</h3>
<pre class="programlisting">#define g_assert_cmphex(n1, cmp, n2)</pre>
<p>Debugging macro to compare to unsigned integers.</p>
<p>This is a variant of <a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()"><code class="function">g_assert_cmpuint()</code></a> that displays the numbers
in hexadecimal notation in the message.</p>
<div class="refsect3">
<a name="g-assert-cmphex.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>n1</p></td>
<td class="parameter_description"><p>an unsigned integer</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>cmp</p></td>
<td class="parameter_description"><p>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n2</p></td>
<td class="parameter_description"><p>another unsigned integer</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpfloat"></a><h3>g_assert_cmpfloat()</h3>
<pre class="programlisting">#define g_assert_cmpfloat(n1,cmp,n2)</pre>
<p>Debugging macro to compare two floating point numbers.</p>
<p>The effect of <code class="literal">g_assert_cmpfloat (n1, op, n2)</code> is
the same as <code class="literal">g_assert_true (n1 op n2)</code>. The advantage
of this macro is that it can produce a message that includes the
actual values of <em class="parameter"><code>n1</code></em>
and <em class="parameter"><code>n2</code></em>
.</p>
<div class="refsect3">
<a name="g-assert-cmpfloat.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>n1</p></td>
<td class="parameter_description"><p>an floating point number</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>cmp</p></td>
<td class="parameter_description"><p>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n2</p></td>
<td class="parameter_description"><p>another floating point number</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpmem"></a><h3>g_assert_cmpmem()</h3>
<pre class="programlisting">#define g_assert_cmpmem(m1, l1, m2, l2)</pre>
<p>Debugging macro to compare memory regions. If the comparison fails,
an error message is logged and the application is either terminated
or the testcase marked as failed.</p>
<p>The effect of <code class="literal">g_assert_cmpmem (m1, l1, m2, l2)</code> is
the same as <code class="literal">g_assert_true (l1 == l2 &amp;&amp; memcmp (m1, m2, l1) == 0)</code>.
The advantage of this macro is that it can produce a message that
includes the actual values of <em class="parameter"><code>l1</code></em>
and <em class="parameter"><code>l2</code></em>
.</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Testing.html#g-assert-cmpmem">g_assert_cmpmem</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">buf</span><span class="symbol">-&gt;</span><span class="normal">data</span><span class="symbol">,</span><span class="normal"> buf</span><span class="symbol">-&gt;</span><span class="normal">len</span><span class="symbol">,</span><span class="normal"> expected</span><span class="symbol">,</span><span class="normal"> </span><span class="keyword">sizeof</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">expected</span><span class="symbol">));</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p></p>
<div class="refsect3">
<a name="g-assert-cmpmem.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>m1</p></td>
<td class="parameter_description"><p>pointer to a buffer</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>l1</p></td>
<td class="parameter_description"><p>length of <em class="parameter"><code>m1</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>m2</p></td>
<td class="parameter_description"><p>pointer to another buffer</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>l2</p></td>
<td class="parameter_description"><p>length of <em class="parameter"><code>m2</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-46.html#api-index-2.46">2.46</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-no-error"></a><h3>g_assert_no_error()</h3>
<pre class="programlisting">#define g_assert_no_error(err)</pre>
<p>Debugging macro to check that a <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a> is not set.</p>
<p>The effect of <code class="literal">g_assert_no_error (err)</code> is
the same as <code class="literal">g_assert_true (err == NULL)</code>. The advantage
of this macro is that it can produce a message that includes
the error message and code.</p>
<div class="refsect3">
<a name="g-assert-no-error.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>err</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a>, possibly <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-20.html#api-index-2.20">2.20</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-error"></a><h3>g_assert_error()</h3>
<pre class="programlisting">#define g_assert_error(err, dom, c)</pre>
<p>Debugging macro to check that a method has returned
the correct <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a>.</p>
<p>The effect of <code class="literal">g_assert_error (err, dom, c)</code> is
the same as <code class="literal">g_assert_true (err != NULL &amp;&amp; err-&gt;domain
== dom &amp;&amp; err-&gt;code == c)</code>. The advantage of this
macro is that it can produce a message that includes the incorrect
error message and code.</p>
<p>This can only be used to test for a specific error. If you want to
test that <em class="parameter"><code>err</code></em>
is set, but don't care what it's set to, just use
<code class="literal">g_assert (err != NULL)</code></p>
<div class="refsect3">
<a name="g-assert-error.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>err</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a>, possibly <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>dom</p></td>
<td class="parameter_description"><p>the expected error domain (a <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>)</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>c</p></td>
<td class="parameter_description"><p>the expected error code</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-20.html#api-index-2.20">2.20</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-true"></a><h3>g_assert_true()</h3>
<pre class="programlisting">#define g_assert_true(expr)</pre>
<p>Debugging macro to check that an expression is true.</p>
<p>If the assertion fails (i.e. the expression is not true),
an error message is logged and the application is either
terminated or the testcase marked as failed.</p>
<p>See <a class="link" href="glib-Testing.html#g-test-set-nonfatal-assertions" title="g_test_set_nonfatal_assertions ()"><code class="function">g_test_set_nonfatal_assertions()</code></a>.</p>
<div class="refsect3">
<a name="g-assert-true.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>expr</p></td>
<td class="parameter_description"><p>the expression to check</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-false"></a><h3>g_assert_false()</h3>
<pre class="programlisting">#define g_assert_false(expr)</pre>
<p>Debugging macro to check an expression is false.</p>
<p>If the assertion fails (i.e. the expression is not false),
an error message is logged and the application is either
terminated or the testcase marked as failed.</p>
<p>See <a class="link" href="glib-Testing.html#g-test-set-nonfatal-assertions" title="g_test_set_nonfatal_assertions ()"><code class="function">g_test_set_nonfatal_assertions()</code></a>.</p>
<div class="refsect3">
<a name="g-assert-false.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>expr</p></td>
<td class="parameter_description"><p>the expression to check</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-null"></a><h3>g_assert_null()</h3>
<pre class="programlisting">#define g_assert_null(expr)</pre>
<p>Debugging macro to check an expression is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
<p>If the assertion fails (i.e. the expression is not <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>),
an error message is logged and the application is either
terminated or the testcase marked as failed.</p>
<p>See <a class="link" href="glib-Testing.html#g-test-set-nonfatal-assertions" title="g_test_set_nonfatal_assertions ()"><code class="function">g_test_set_nonfatal_assertions()</code></a>.</p>
<div class="refsect3">
<a name="g-assert-null.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>expr</p></td>
<td class="parameter_description"><p>the expression to check</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-nonnull"></a><h3>g_assert_nonnull()</h3>
<pre class="programlisting">#define g_assert_nonnull(expr)</pre>
<p>Debugging macro to check an expression is not <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
<p>If the assertion fails (i.e. the expression is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>),
an error message is logged and the application is either
terminated or the testcase marked as failed.</p>
<p>See <a class="link" href="glib-Testing.html#g-test-set-nonfatal-assertions" title="g_test_set_nonfatal_assertions ()"><code class="function">g_test_set_nonfatal_assertions()</code></a>.</p>
<div class="refsect3">
<a name="g-assert-nonnull.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>expr</p></td>
<td class="parameter_description"><p>the expression to check</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-40.html#api-index-2.40">2.40</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-set-nonfatal-assertions"></a><h3>g_test_set_nonfatal_assertions ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_set_nonfatal_assertions (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Changes the behaviour of <a class="link" href="glib-Testing.html#g-assert-cmpstr" title="g_assert_cmpstr()"><code class="function">g_assert_cmpstr()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmpint" title="g_assert_cmpint()"><code class="function">g_assert_cmpint()</code></a>,
<a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()"><code class="function">g_assert_cmpuint()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmphex" title="g_assert_cmphex()"><code class="function">g_assert_cmphex()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmpfloat" title="g_assert_cmpfloat()"><code class="function">g_assert_cmpfloat()</code></a>,
<a class="link" href="glib-Testing.html#g-assert-true" title="g_assert_true()"><code class="function">g_assert_true()</code></a>, <a class="link" href="glib-Testing.html#g-assert-false" title="g_assert_false()"><code class="function">g_assert_false()</code></a>, <a class="link" href="glib-Testing.html#g-assert-null" title="g_assert_null()"><code class="function">g_assert_null()</code></a>, <a class="link" href="glib-Testing.html#g-assert-no-error" title="g_assert_no_error()"><code class="function">g_assert_no_error()</code></a>,
<a class="link" href="glib-Testing.html#g-assert-error" title="g_assert_error()"><code class="function">g_assert_error()</code></a>, <a class="link" href="glib-Testing.html#g-test-assert-expected-messages" title="g_test_assert_expected_messages"><code class="function">g_test_assert_expected_messages()</code></a> and the various
g_test_trap_assert_*() macros to not abort to program, but instead
call <a class="link" href="glib-Testing.html#g-test-fail" title="g_test_fail ()"><code class="function">g_test_fail()</code></a> and continue. (This also changes the behavior of
<a class="link" href="glib-Testing.html#g-test-fail" title="g_test_fail ()"><code class="function">g_test_fail()</code></a> so that it will not cause the test program to abort
after completing the failed test.)</p>
<p>Note that the <a class="link" href="glib-Testing.html#g-assert-not-reached" title="g_assert_not_reached"><code class="function">g_assert_not_reached()</code></a> and <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a> are not
affected by this.</p>
<p>This function can only be called after <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>.</p>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GTestFixtureFunc"></a><h3>GTestFixtureFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
<span class="c_punctuation">(</span>*GTestFixtureFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> fixture</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> user_data</code></em>);</pre>
<p>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.</p>
<p><em class="parameter"><code>user_data</code></em>
is a pointer to the data that was given when registering
the test case.</p>
<p><em class="parameter"><code>fixture</code></em>
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 <em class="parameter"><code>fixture</code></em>
will be equal to <em class="parameter"><code>user_data</code></em>
.</p>
<div class="refsect3">
<a name="GTestFixtureFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>fixture</p></td>
<td class="parameter_description"><p> the test fixture. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL must not be passed as the value in, out, in-out; or as a return value."><span class="acronym">not nullable</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>the data provided when registering the test</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-create-case"></a><h3>g_test_create_case ()</h3>
<pre class="programlisting"><a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="returnvalue">GTestCase</span></a> *
g_test_create_case (<em class="parameter"><code>const <span class="type">char</span> *test_name</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> data_size</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> test_data</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_setup</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_test</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_teardown</code></em>);</pre>
<p>Create a new <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a>, named <em class="parameter"><code>test_name</code></em>
, this API is fairly
low level, calling <a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()"><code class="function">g_test_add()</code></a> or <a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()"><code class="function">g_test_add_func()</code></a> is preferable.
When this test is executed, a fixture structure of size <em class="parameter"><code>data_size</code></em>
will be automatically allocated and filled with zeros. Then <em class="parameter"><code>data_setup</code></em>
is
called to initialize the fixture. After fixture setup, the actual test
function <em class="parameter"><code>data_test</code></em>
is called. Once the test run completes, the
fixture structure is torn down by calling <em class="parameter"><code>data_teardown</code></em>
and
after that the memory is automatically released by the test framework.</p>
<p>Splitting up a test run into fixture setup, test function and
fixture teardown is most useful if the same fixture is used for
multiple tests. In this cases, <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a> will be
called with the same fixture, but varying <em class="parameter"><code>test_name</code></em>
and
<em class="parameter"><code>data_test</code></em>
arguments.</p>
<div class="refsect3">
<a name="g-test-create-case.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>test_name</p></td>
<td class="parameter_description"><p>the name for the test case</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data_size</p></td>
<td class="parameter_description"><p>the size of the fixture data structure</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_data</p></td>
<td class="parameter_description"><p>test data argument for the test functions</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data_setup</p></td>
<td class="parameter_description"><p> the function to set up the fixture data. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>data_test</p></td>
<td class="parameter_description"><p> the actual test function. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span></td>
</tr>
<tr>
<td class="parameter_name"><p>data_teardown</p></td>
<td class="parameter_description"><p> the function to teardown the fixture data. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-create-case.returns"></a><h4>Returns</h4>
<p> a newly allocated <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a>.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-create-suite"></a><h3>g_test_create_suite ()</h3>
<pre class="programlisting"><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *
g_test_create_suite (<em class="parameter"><code>const <span class="type">char</span> *suite_name</code></em>);</pre>
<p>Create a new test suite with the name <em class="parameter"><code>suite_name</code></em>
.</p>
<div class="refsect3">
<a name="g-test-create-suite.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>suite_name</p></td>
<td class="parameter_description"><p>a name for the suite</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-create-suite.returns"></a><h4>Returns</h4>
<p> A newly allocated <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> instance.</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-get-root"></a><h3>g_test_get_root ()</h3>
<pre class="programlisting"><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *
g_test_get_root (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Get the toplevel test suite for the test path API.</p>
<div class="refsect3">
<a name="g-test-get-root.returns"></a><h4>Returns</h4>
<p> the toplevel <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-suite-add"></a><h3>g_test_suite_add ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_suite_add (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a> *test_case</code></em>);</pre>
<p>Adds <em class="parameter"><code>test_case</code></em>
to <em class="parameter"><code>suite</code></em>
.</p>
<div class="refsect3">
<a name="g-test-suite-add.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>suite</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>test_case</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-suite-add-suite"></a><h3>g_test_suite_add_suite ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_test_suite_add_suite (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>,
<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *nestedsuite</code></em>);</pre>
<p>Adds <em class="parameter"><code>nestedsuite</code></em>
to <em class="parameter"><code>suite</code></em>
.</p>
<div class="refsect3">
<a name="g-test-suite-add-suite.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>suite</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>nestedsuite</p></td>
<td class="parameter_description"><p>another <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-run-suite"></a><h3>g_test_run_suite ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span>
g_test_run_suite (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>);</pre>
<p>Execute the tests within <em class="parameter"><code>suite</code></em>
and all nested <a href="glib-Testing.html#GTestSuite"><span class="type">GTestSuites</span></a>.
The test suites to be executed are filtered according to
test path arguments (<code class="literal">-p testpath</code>) as parsed by <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>.
See the <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()"><code class="function">g_test_run()</code></a> documentation for more information on the
order that tests are run in.</p>
<p>g_test_run_suite() or <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()"><code class="function">g_test_run()</code></a> may only be called once
in a program.</p>
<div class="refsect3">
<a name="g-test-run-suite.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>suite</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-test-run-suite.returns"></a><h4>Returns</h4>
<p> 0 on success</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
</div>
</div>
<div class="refsect1">
<a name="glib-Testing.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GTestFileType"></a><h3>enum GTestFileType</h3>
<p>The type of file to return the filename for, when used with
<a class="link" href="glib-Testing.html#g-test-build-filename" title="g_test_build_filename ()"><code class="function">g_test_build_filename()</code></a>.</p>
<p>These two options correspond rather directly to the 'dist' and
'built' terminology that automake uses and are explicitly used to
distinguish between the 'srcdir' and 'builddir' being separate. All
files in your project should either be dist (in the
<code class="literal">DIST_EXTRA</code> or <code class="literal">dist_schema_DATA</code>
sense, in which case they will always be in the srcdir) or built (in
the <code class="literal">BUILT_SOURCES</code> sense, in which case they will
always be in the builddir).</p>
<p>Note: as a general rule of automake, files that are generated only as
part of the build-from-git process (but then are distributed with the
tarball) always go in srcdir (even if doing a srcdir != builddir
build from git) and are considered as distributed files.</p>
<div class="refsect3">
<a name="GTestFileType.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="enum_members_description">
<col width="200px" class="enum_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-DIST:CAPS"></a>G_TEST_DIST</p></td>
<td class="enum_member_description">
<p>a file that was included in the distribution tarball</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-BUILT:CAPS"></a>G_TEST_BUILT</p></td>
<td class="enum_member_description">
<p>a file that was built on the compiling machine</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-38.html#api-index-2.38">2.38</a></p>
</div>
<hr>
<div class="refsect2">
<a name="GTestTrapFlags"></a><h3>enum GTestTrapFlags</h3>
<div class="warning">
<p><code class="literal">GTestTrapFlags</code> is deprecated and should not be used in newly-written code.</p>
<p><a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> is used only with <a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()"><code class="function">g_test_trap_fork()</code></a>,
which is deprecated. <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> uses
<span class="type">GTestTrapSubprocessFlags</span>.</p>
</div>
<p>Test traps are guards around forked tests.
These flags determine what traps to set.</p>
<div class="refsect3">
<a name="GTestTrapFlags.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="enum_members_description">
<col width="200px" class="enum_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-TRAP-SILENCE-STDOUT:CAPS"></a>G_TEST_TRAP_SILENCE_STDOUT</p></td>
<td class="enum_member_description">
<p>Redirect stdout of the test child to
<code class="literal">/dev/null</code> so it cannot be observed on the console during test
runs. The actual output is still captured though to allow later
tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()"><code class="function">g_test_trap_assert_stdout()</code></a>.</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-TRAP-SILENCE-STDERR:CAPS"></a>G_TEST_TRAP_SILENCE_STDERR</p></td>
<td class="enum_member_description">
<p>Redirect stderr of the test child to
<code class="literal">/dev/null</code> so it cannot be observed on the console during test
runs. The actual output is still captured though to allow later
tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a>.</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-TRAP-INHERIT-STDIN:CAPS"></a>G_TEST_TRAP_INHERIT_STDIN</p></td>
<td class="enum_member_description">
<p>If this flag is given, stdin of the
child process is shared with stdin of its parent process.
It is redirected to <code class="literal">/dev/null</code> otherwise.</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GTestSubprocessFlags"></a><h3>enum GTestSubprocessFlags</h3>
<p>Flags to pass to <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> to control input and output.</p>
<p>Note that in contrast with <a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()"><code class="function">g_test_trap_fork()</code></a>, the default is to
not show stdout and stderr.</p>
<div class="refsect3">
<a name="GTestSubprocessFlags.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="enum_members_description">
<col width="200px" class="enum_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-SUBPROCESS-INHERIT-STDIN:CAPS"></a>G_TEST_SUBPROCESS_INHERIT_STDIN</p></td>
<td class="enum_member_description">
<p>If this flag is given, the child
process will inherit the parent's stdin. Otherwise, the child's
stdin is redirected to <code class="literal">/dev/null</code>.</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-SUBPROCESS-INHERIT-STDOUT:CAPS"></a>G_TEST_SUBPROCESS_INHERIT_STDOUT</p></td>
<td class="enum_member_description">
<p>If this flag is given, the child
process will inherit the parent's stdout. Otherwise, the child's
stdout will not be visible, but it will be captured to allow
later tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()"><code class="function">g_test_trap_assert_stdout()</code></a>.</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="G-TEST-SUBPROCESS-INHERIT-STDERR:CAPS"></a>G_TEST_SUBPROCESS_INHERIT_STDERR</p></td>
<td class="enum_member_description">
<p>If this flag is given, the child
process will inherit the parent's stderr. Otherwise, the child's
stderr will not be visible, but it will be captured to allow
later tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a>.</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GTestCase"></a><h3>GTestCase</h3>
<pre class="programlisting">typedef struct GTestCase GTestCase;
</pre>
<p>An opaque structure representing a test case.</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestSuite"></a><h3>GTestSuite</h3>
<pre class="programlisting">typedef struct GTestSuite GTestSuite;
</pre>
<p>An opaque structure representing a test suite.</p>
</div>
</div>
<div class="refsect1">
<a name="glib-Testing.see-also"></a><h2>See Also</h2>
<p>gtester, gtester-report</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>