| <!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</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <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-Windows-Compatibility-Functions.html" title="Windows Compatibility Functions"> |
| <meta name="generator" content="GTK-Doc V1.14 (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="2"> |
| <tr valign="middle"> |
| <td><a accesskey="p" href="glib-Bookmark-file-parser.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> |
| <td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> |
| <th width="100%" align="center">GLib Reference Manual</th> |
| <td><a accesskey="n" href="glib-Windows-Compatibility-Functions.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> |
| </tr> |
| <tr><td colspan="5" class="shortcuts"> |
| <a href="#glib-Testing.synopsis" class="shortcut">Top</a> |
| | |
| <a href="#glib-Testing.description" class="shortcut">Description</a> |
| </td></tr> |
| </table> |
| <div class="refentry" title="Testing"> |
| <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 valign="top" align="right"></td> |
| </tr></table></div> |
| <div class="refsynopsisdiv" title="Synopsis"> |
| <a name="glib-Testing.synopsis"></a><h2>Synopsis</h2> |
| <pre class="synopsis"> |
| #include <glib.h> |
| |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-minimized-result" title="g_test_minimized_result ()">g_test_minimized_result</a> (<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>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-maximized-result" title="g_test_maximized_result ()">g_test_maximized_result</a> (<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>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()">g_test_init</a> (<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>); |
| #define <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick">g_test_quick</a> |
| #define <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow">g_test_slow</a> |
| #define <a class="link" href="glib-Testing.html#g-test-thorough" title="g_test_thorough">g_test_thorough</a> |
| #define <a class="link" href="glib-Testing.html#g-test-perf" title="g_test_perf">g_test_perf</a> |
| #define <a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose">g_test_verbose</a> |
| #define <a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet">g_test_quiet</a> |
| <span class="returnvalue">int</span> <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()">g_test_run</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()">g_test_add_func</a> (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>, |
| <em class="parameter"><code><span class="type">void</span> (test_funcvoid) ()</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-add-data-func" title="g_test_add_data_func ()">g_test_add_data_func</a> (<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><span class="type">void</span> (test_funcgconstpointer) ()</code></em>); |
| #define <a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()">g_test_add</a> (testpath, |
| Fixture, |
| tdata, |
| fsetup, |
| ftest, |
| fteardown) |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-message" title="g_test_message ()">g_test_message</a> (<em class="parameter"><code>const <span class="type">char</span> *format</code></em>, |
| <em class="parameter"><code>...</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-bug-base" title="g_test_bug_base ()">g_test_bug_base</a> (<em class="parameter"><code>const <span class="type">char</span> *uri_pattern</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-bug" title="g_test_bug ()">g_test_bug</a> (<em class="parameter"><code>const <span class="type">char</span> *bug_uri_snippet</code></em>); |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> (<a class="link" href="glib-Testing.html#GTestLogFatalFunc" title="GTestLogFatalFunc ()">*GTestLogFatalFunc</a>) (<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>); |
| <span class="returnvalue">void</span> <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> (<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>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-timer-start" title="g_test_timer_start ()">g_test_timer_start</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">double</span> <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()">g_test_timer_elapsed</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">double</span> <a class="link" href="glib-Testing.html#g-test-timer-last" title="g_test_timer_last ()">g_test_timer_last</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-queue-free" title="g_test_queue_free ()">g_test_queue_free</a> (<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>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()">g_test_queue_destroy</a> (<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>); |
| #define <a class="link" href="glib-Testing.html#g-test-queue-unref" title="g_test_queue_unref()">g_test_queue_unref</a> (gobject) |
| enum <a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags">GTestTrapFlags</a>; |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()">g_test_trap_fork</a> (<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>); |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Testing.html#g-test-trap-has-passed" title="g_test_trap_has_passed ()">g_test_trap_has_passed</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-Testing.html#g-test-trap-reached-timeout" title="g_test_trap_reached_timeout ()">g_test_trap_reached_timeout</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| #define <a class="link" href="glib-Testing.html#g-test-trap-assert-passed" title="g_test_trap_assert_passed">g_test_trap_assert_passed</a> |
| #define <a class="link" href="glib-Testing.html#g-test-trap-assert-failed" title="g_test_trap_assert_failed">g_test_trap_assert_failed</a> |
| #define <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()">g_test_trap_assert_stdout</a> (soutpattern) |
| #define <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> (soutpattern) |
| #define <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()">g_test_trap_assert_stderr</a> (serrpattern) |
| #define <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> (serrpattern) |
| #define <a class="link" href="glib-Testing.html#g-test-rand-bit" title="g_test_rand_bit">g_test_rand_bit</a> |
| <a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a> <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()">g_test_rand_int</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a> <a class="link" href="glib-Testing.html#g-test-rand-int-range" title="g_test_rand_int_range ()">g_test_rand_int_range</a> (<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>); |
| <span class="returnvalue">double</span> <a class="link" href="glib-Testing.html#g-test-rand-double" title="g_test_rand_double ()">g_test_rand_double</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">double</span> <a class="link" href="glib-Testing.html#g-test-rand-double-range" title="g_test_rand_double_range ()">g_test_rand_double_range</a> (<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>); |
| #define <a class="link" href="glib-Testing.html#g-assert" title="g_assert()">g_assert</a> (expr) |
| #define <a class="link" href="glib-Testing.html#g-assert-not-reached" title="g_assert_not_reached">g_assert_not_reached</a> |
| #define <a class="link" href="glib-Testing.html#g-assert-cmpstr" title="g_assert_cmpstr()">g_assert_cmpstr</a> (s1, |
| cmp, |
| s2) |
| #define <a class="link" href="glib-Testing.html#g-assert-cmpint" title="g_assert_cmpint()">g_assert_cmpint</a> (n1, |
| cmp, |
| n2) |
| #define <a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()">g_assert_cmpuint</a> (n1, |
| cmp, |
| n2) |
| #define <a class="link" href="glib-Testing.html#g-assert-cmphex" title="g_assert_cmphex()">g_assert_cmphex</a> (n1, |
| cmp, |
| n2) |
| #define <a class="link" href="glib-Testing.html#g-assert-cmpfloat" title="g_assert_cmpfloat()">g_assert_cmpfloat</a> (n1, |
| cmp, |
| n2) |
| #define <a class="link" href="glib-Testing.html#g-assert-no-error" title="g_assert_no_error()">g_assert_no_error</a> (err) |
| #define <a class="link" href="glib-Testing.html#g-assert-error" title="g_assert_error()">g_assert_error</a> (err, |
| dom, |
| c) |
| typedef <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase">GTestCase</a>; |
| typedef <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite">GTestSuite</a>; |
| <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="returnvalue">GTestCase</span></a>* <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()">g_test_create_case</a> (<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><span class="type">void</span> (data_setupvoid) ()</code></em>, |
| <em class="parameter"><code><span class="type">void</span> (data_testvoid) ()</code></em>, |
| <em class="parameter"><code><span class="type">void</span> (data_teardownvoid) ()</code></em>); |
| <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a>* <a class="link" href="glib-Testing.html#g-test-create-suite" title="g_test_create_suite ()">g_test_create_suite</a> (<em class="parameter"><code>const <span class="type">char</span> *suite_name</code></em>); |
| <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a>* <a class="link" href="glib-Testing.html#g-test-get-root" title="g_test_get_root ()">g_test_get_root</a> (<em class="parameter"><code><span class="type">void</span></code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-suite-add" title="g_test_suite_add ()">g_test_suite_add</a> (<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>); |
| <span class="returnvalue">void</span> <a class="link" href="glib-Testing.html#g-test-suite-add-suite" title="g_test_suite_add_suite ()">g_test_suite_add_suite</a> (<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>); |
| <span class="returnvalue">int</span> <a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()">g_test_run_suite</a> (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>); |
| </pre> |
| </div> |
| <div class="refsect1" title="Description"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term">Test case</span></p></td> |
| <td><p> |
| Tests (test methods) are grouped together with their |
| fixture into test cases. |
| </p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term">Fixture</span></p></td> |
| <td><p> |
| 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></td> |
| </tr> |
| <tr> |
| <td><p><span class="term">Test suite</span></p></td> |
| <td><p> |
| 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></td> |
| </tr> |
| </tbody> |
| </table></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 string and numerical 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>. 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> |
| </div> |
| <div class="refsect1" title="Details"> |
| <a name="glib-Testing.details"></a><h2>Details</h2> |
| <div class="refsect2" title="g_test_minimized_result ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>minimized_quantity</code></em> :</span></p></td> |
| <td>the reported value |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td> |
| <td>the format string of the report message |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td> |
| <td>arguments to pass to the <code class="function">printf()</code> function |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_maximized_result ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>maximized_quantity</code></em> :</span></p></td> |
| <td>the reported value |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td> |
| <td>the format string of the report message |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td> |
| <td>arguments to pass to the <code class="function">printf()</code> function |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_init ()"> |
| <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. |
| So far, the following arguments are understood: |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><code class="option">-l</code></span></p></td> |
| <td><p> |
| list test cases available in a test executable. |
| </p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">--seed=<em class="replaceable"><code>RANDOMSEED</code></em></code></span></p></td> |
| <td><p> |
| provide a random seed to reproduce test runs using random numbers. |
| </p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">--verbose</code></span></p></td> |
| <td><p>run tests verbosely.</p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">-q</code>, <code class="option">--quiet</code></span></p></td> |
| <td><p>run tests quietly.</p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">-p <em class="replaceable"><code>TESTPATH</code></em></code></span></p></td> |
| <td><p> |
| execute all tests matching <em class="replaceable"><code>TESTPATH</code></em>. |
| </p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">-m {perf|slow|thorough|quick}</code></span></p></td> |
| <td> |
| <p> |
| execute tests according to these test modes: |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term">perf</span></p></td> |
| <td><p> |
| performance tests, may take long and report results. |
| </p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term">slow, thorough</span></p></td> |
| <td><p> |
| slow and thorough tests, may take quite long and |
| maximize coverage. |
| </p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term">quick</span></p></td> |
| <td><p> |
| quick tests, should run really quickly and give good coverage. |
| </p></td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">--debug-log</code></span></p></td> |
| <td><p>debug test logging output.</p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">-k</code>, <code class="option">--keep-going</code></span></p></td> |
| <td><p>gtester-specific argument.</p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">--GTestLogFD <em class="replaceable"><code>N</code></em></code></span></p></td> |
| <td><p>gtester-specific argument.</p></td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><code class="option">--GTestSkipCount <em class="replaceable"><code>N</code></em></code></span></p></td> |
| <td><p>gtester-specific argument.</p></td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p> |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>argc</code></em> :</span></p></td> |
| <td>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. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>argv</code></em> :</span></p></td> |
| <td>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. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td> |
| <td>Reserved for future extension. Currently, you must pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_quick"> |
| <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. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_slow"> |
| <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. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_thorough"> |
| <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. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_perf"> |
| <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> |
| <hr> |
| <div class="refsect2" title="g_test_verbose"> |
| <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. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_quiet"> |
| <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. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_run ()"> |
| <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 (-p <em class="replaceable"><code>testpath</code></em>) 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> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> 0 on success |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_add_func ()"> |
| <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><span class="type">void</span> (test_funcvoid) ()</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> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td> |
| <td>Slash-separated test case path name for the test. |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_add_data_func ()"> |
| <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><span class="type">void</span> (test_funcgconstpointer) ()</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> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td> |
| <td>Slash-separated test case path name for the test. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>test_data</code></em> :</span></p></td> |
| <td>Test data argument for the test function. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>gconstpointer</code></em> :</span></p></td> |
| <td> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_add()"> |
| <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 function may be provided |
| though, 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>. |
| <a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()"><code class="function">g_test_add()</code></a> 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 first argument in |
| a type safe manner. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td> |
| <td>The test path for a new test case. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>Fixture</code></em> :</span></p></td> |
| <td>The type of a fixture data structure. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>tdata</code></em> :</span></p></td> |
| <td>Data argument for the test functions. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fsetup</code></em> :</span></p></td> |
| <td>The function to set up the fixture data. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>ftest</code></em> :</span></p></td> |
| <td>The actual test function. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fteardown</code></em> :</span></p></td> |
| <td>The function to tear down the fixture data. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_message ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td> |
| <td>the format string |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td> |
| <td>printf-like arguments to <em class="parameter"><code>format</code></em> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_bug_base ()"> |
| <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 |
| '<code class="literal">s</code>' within <em class="parameter"><code>uri_pattern</code></em> if that is present. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>uri_pattern</code></em> :</span></p></td> |
| <td>the base pattern for bug URIs |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_bug ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>bug_uri_snippet</code></em> :</span></p></td> |
| <td>Bug specific bug tracker URI portion. |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GTestLogFatalFunc ()"> |
| <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> (*GTestLogFatalFunc) (<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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td> |
| <td>the log domain of the message |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td> |
| <td>the log level of the message (including the fatal and recursion flags) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>message</code></em> :</span></p></td> |
| <td>the message to process |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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 |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_log_set_fatal_handler ()"> |
| <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> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>log_func</code></em> :</span></p></td> |
| <td>the log handler function. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>data passed to the log handler. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_timer_start ()"> |
| <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 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_timer_elapsed ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the time since the last start of the timer, as a double |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_timer_last ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> 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 |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_queue_free ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>gfree_pointer</code></em> :</span></p></td> |
| <td>the pointer to be stored. |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_queue_destroy ()"> |
| <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 @<code class="function">destroy_func()</code> 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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>destroy_func</code></em> :</span></p></td> |
| <td>Destroy callback for teardown phase. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>destroy_data</code></em> :</span></p></td> |
| <td>Destroy callback data. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_queue_unref()"> |
| <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="/usr/share/gtk-doc/html/gobject/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="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>gobject</code></em> :</span></p></td> |
| <td>the object to unref |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="enum GTestTrapFlags"> |
| <a name="GTestTrapFlags"></a><h3>enum GTestTrapFlags</h3> |
| <pre class="programlisting">typedef enum { |
| G_TEST_TRAP_SILENCE_STDOUT = 1 << 7, |
| G_TEST_TRAP_SILENCE_STDERR = 1 << 8, |
| G_TEST_TRAP_INHERIT_STDIN = 1 << 9 |
| } GTestTrapFlags; |
| </pre> |
| <p> |
| Test traps are guards around forked tests. These flags |
| determine what traps to set. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><a name="G-TEST-TRAP-SILENCE-STDOUT:CAPS"></a><span class="term"><code class="literal">G_TEST_TRAP_SILENCE_STDOUT</code></span></p></td> |
| <td>Redirect stdout of the test child to |
| <code class="filename">/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>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-TEST-TRAP-SILENCE-STDERR:CAPS"></a><span class="term"><code class="literal">G_TEST_TRAP_SILENCE_STDERR</code></span></p></td> |
| <td>Redirect stderr of the test child to |
| <code class="filename">/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>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-TEST-TRAP-INHERIT-STDIN:CAPS"></a><span class="term"><code class="literal">G_TEST_TRAP_INHERIT_STDIN</code></span></p></td> |
| <td>If this flag is given, stdin of the forked |
| child process is shared with stdin of its parent process. It is |
| redirected to <code class="filename">/dev/null</code> otherwise. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_fork ()"> |
| <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> |
| <p> |
| Fork the current test program to execute a test case that might |
| not return or that might abort. The forked test case is aborted |
| and considered failing if its run time exceeds <em class="parameter"><code>usec_timeout</code></em>. |
| </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> |
| <p> |
| </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="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> |
| <p> |
| This function is implemented only on Unix platforms. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>usec_timeout</code></em> :</span></p></td> |
| <td>Timeout for the forked test in micro seconds. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>test_trap_flags</code></em> :</span></p></td> |
| <td>Flags to modify forking behaviour. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <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. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_has_passed ()"> |
| <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-fork" title="g_test_trap_fork ()"><code class="function">g_test_trap_fork()</code></a> call. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the last forked child terminated successfully. |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_reached_timeout ()"> |
| <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-fork" title="g_test_trap_fork ()"><code class="function">g_test_trap_fork()</code></a> call. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the last forked child got killed due to a fork timeout. |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_assert_passed"> |
| <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 forked test passed. See <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>. |
| </p> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_assert_failed"> |
| <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 forked test failed. See <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>. |
| </p> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_assert_stdout()"> |
| <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 forked test matches <em class="parameter"><code>soutpattern</code></em>. |
| See <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>soutpattern</code></em> :</span></p></td> |
| <td>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_assert_stdout_unmatched()"> |
| <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 forked test does not match |
| <em class="parameter"><code>soutpattern</code></em>. See <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>soutpattern</code></em> :</span></p></td> |
| <td>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_assert_stderr()"> |
| <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 forked test matches <em class="parameter"><code>serrpattern</code></em>. |
| See <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>serrpattern</code></em> :</span></p></td> |
| <td>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_trap_assert_stderr_unmatched()"> |
| <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 forked test does not match |
| <em class="parameter"><code>serrpattern</code></em>. See <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>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>serrpattern</code></em> :</span></p></td> |
| <td>a glob-style <a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a> |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_rand_bit"> |
| <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 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_rand_int ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a random number from the seeded random number generator. |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_rand_int_range ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>begin</code></em> :</span></p></td> |
| <td>the minimum value returned by this function |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>end</code></em> :</span></p></td> |
| <td>the smallest value not to be returned by this function |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a number with <em class="parameter"><code>begin</code></em> <= number < <em class="parameter"><code>end</code></em>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_rand_double ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a random number from the seeded random number generator. |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_rand_double_range ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>range_start</code></em> :</span></p></td> |
| <td>the minimum value returned by this function |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>range_end</code></em> :</span></p></td> |
| <td>the minimum value not returned by this function |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a number with <em class="parameter"><code>range_start</code></em> <= number < <em class="parameter"><code>range_end</code></em>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert()"> |
| <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 |
| <span class="type">G_DISABLE_ASSERT</span> when compiling the application. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>expr</code></em> :</span></p></td> |
| <td>the expression to check. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_not_reached"> |
| <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 |
| <span class="type">G_DISABLE_ASSERT</span> when compiling the application. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_cmpstr()"> |
| <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 terminate the application with a warning message |
| if a string comparison fails. |
| 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 (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> |
| |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>s1</code></em> :</span></p></td> |
| <td>a string (may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td> |
| <td>The comparison operator to use. One of ==, !=, <, >, <=, >=. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>s2</code></em> :</span></p></td> |
| <td>another string (may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>) |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_cmpint()"> |
| <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 terminate the application with a warning message |
| if an integer comparison fails. |
| </p> |
| <p> |
| The effect of <code class="literal">g_assert_cmpint (n1, op, n2)</code> is the same |
| as <code class="literal">g_assert (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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td> |
| <td>an integer |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td> |
| <td>The comparison operator to use. One of ==, !=, <, >, <=, >=. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td> |
| <td>another integer |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_cmpuint()"> |
| <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 terminate the application with a warning message |
| if an unsigned integer comparison fails. |
| </p> |
| <p> |
| The effect of <code class="literal">g_assert_cmpuint (n1, op, n2)</code> is the same |
| as <code class="literal">g_assert (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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td> |
| <td>an unsigned integer |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td> |
| <td>The comparison operator to use. One of ==, !=, <, >, <=, >=. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td> |
| <td>another unsigned integer |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_cmphex()"> |
| <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 terminate the application with a warning message |
| if an unsigned integer comparison fails. 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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td> |
| <td>an unsigned integer |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td> |
| <td>The comparison operator to use. One of ==, !=, <, >, <=, >=. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td> |
| <td>another unsigned integer |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_cmpfloat()"> |
| <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 terminate the application with a warning message |
| if a floating point number comparison fails. |
| </p> |
| <p> |
| The effect of <code class="literal">g_assert_cmpfloat (n1, op, n2)</code> is the same |
| as <code class="literal">g_assert (n1 op n2)</code>. The advantage of this function |
| 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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td> |
| <td>an floating point number |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td> |
| <td>The comparison operator to use. One of ==, !=, <, >, <=, >=. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td> |
| <td>another floating point number |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_no_error()"> |
| <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 terminate the application with a warning message |
| if a method has returned a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>. |
| </p> |
| <p> |
| The effect of <code class="literal">g_assert_no_error (err)</code> is the same |
| as <code class="literal">g_assert (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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Error-Reporting.html#GError" title="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> |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.20</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_assert_error()"> |
| <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 terminate the application with a warning message |
| if a method has not returned the correct <a class="link" href="glib-Error-Reporting.html#GError" title="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 (err != NULL && err->domain == dom && err->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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Error-Reporting.html#GError" title="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> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>dom</code></em> :</span></p></td> |
| <td>the expected error domain (a <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>) |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>c</code></em> :</span></p></td> |
| <td>the expected error code |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.20</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GTestCase"> |
| <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" title="GTestSuite"> |
| <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> |
| <hr> |
| <div class="refsect2" title="g_test_create_case ()"> |
| <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><span class="type">void</span> (data_setupvoid) ()</code></em>, |
| <em class="parameter"><code><span class="type">void</span> (data_testvoid) ()</code></em>, |
| <em class="parameter"><code><span class="type">void</span> (data_teardownvoid) ()</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 allocated and filled with 0s. Then <code class="function">data_setup()</code> is called |
| to initialize the fixture. After fixture setup, the actual test |
| function <code class="function">data_test()</code> is called. Once the test run completed, the |
| fixture structure is torn down by calling <code class="function">data_teardown()</code> and |
| after that the memory is released. |
| </p> |
| <p> |
| Splitting up a test run into fixture setup, test function and |
| fixture teardown is most usful 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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>test_name</code></em> :</span></p></td> |
| <td>the name for the test case |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>data_size</code></em> :</span></p></td> |
| <td>the size of the fixture data structure |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>test_data</code></em> :</span></p></td> |
| <td>test data argument for the test functions |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a newly allocated <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_create_suite ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>suite_name</code></em> :</span></p></td> |
| <td>a name for the suite |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> A newly allocated <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> instance. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_get_root ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the toplevel <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> |
| |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_suite_add ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>suite</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>test_case</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_suite_add_suite ()"> |
| <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="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>suite</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>nestedsuite</code></em> :</span></p></td> |
| <td>another <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_test_run_suite ()"> |
| <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 (-p <em class="replaceable"><code>testpath</code></em>) |
| 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> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>suite</code></em> :</span></p></td> |
| <td>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> 0 on success |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.16</p> |
| </div> |
| </div> |
| <div class="refsect1" title="See Also"> |
| <a name="glib-Testing.see-also"></a><h2>See Also</h2> |
| <p> |
| <a href="gtester.html">gtester</a>, |
| <a href="gtester-report.html">gtester-report</a> |
| </p> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr> |
| Generated by GTK-Doc V1.14</div> |
| </body> |
| </html> |