typedef typedefG_BEGIN_DECLS struct GTestCase | GTestCase |
typedef struct GTestSuite | GTestSuite |
IMPORT_C int | g_strcmp0 | ( | const char * | str1, |
const char * | str2 | |||
) |
g_strcmp0: : a C string or NULL : another C string or NULL
Compares and like strcmp(). Handles NULL gracefully by sorting it before non-NULL strings.
Returns: -1, 0 or 1, if is <, == or > than .
Since: 2.16
IMPORT_C void | g_test_minimized_result | ( | double | minimized_quantity, |
const char * | format, | |||
... | ||||
) |
IMPORT_C void IMPORT_C void | g_test_maximized_result | ( | double | maximized_quantity, |
const char * | format, | |||
... | ||||
) |
IMPORT_C void IMPORT_C void IMPORT_C void | g_test_init | ( | int * | argc, |
char *** | argv, | |||
... | ||||
) |
g_test_init: : Address of the parameter of the main() function. Changed if any arguments were handled. : Address of the parameter of main(). Any parameters understood by g_test_init() stripped before return. : Reserved for future extension. Currently, you must pass NULL.
Initialize the GLib testing framework, e.g. by seeding the test random number generator, the name for g_get_prgname() and parsing test related command line args. So far, the following arguments are understood: <variablelist> <varlistentry> <option>-l</option> <listitem>
list test cases available in a test executable.
</listitem> </varlistentry> <varlistentry> <option>--seed=<replaceable>RANDOMSEED</replaceable></option> <listitem>
provide a random seed to reproduce test runs using random numbers.
</listitem> </varlistentry> <varlistentry> <option>--verbose</option> <listitem>
run tests verbosely.
</listitem> </varlistentry> <varlistentry> <option>-q</option>, <option>--quiet</option> <listitem>
run tests quietly.
</listitem> </varlistentry> <varlistentry> <option>-p <replaceable>TESTPATH</replaceable></option> <listitem>
execute all tests matching <replaceable>TESTPATH</replaceable>.
</listitem> </varlistentry> <varlistentry> <option>-m {perf|slow|thorough|quick}</option> <listitem>
execute tests according to these test modes: <variablelist> <varlistentry> perf <listitem>
performance tests, may take long and report results.
</listitem> </varlistentry> <varlistentry> slow, thorough <listitem>
slow and thorough tests, may take quite long and maximize coverage.
</listitem> </varlistentry> <varlistentry> quick <listitem>
quick tests, should run really quickly and give good coverage.
</listitem> </varlistentry> </variablelist>
</listitem> </varlistentry> <varlistentry> <option>--debug-log</option> <listitem>
debug test logging output.
</listitem> </varlistentry> <varlistentry> <option>-k</option>, <option>--keep-going</option> <listitem>
gtester-specific argument.
</listitem> </varlistentry> <varlistentry> <option>--GTestLogFD <replaceable>N</replaceable></option> <listitem>
gtester-specific argument.
</listitem> </varlistentry> <varlistentry> <option>--GTestSkipCount <replaceable>N</replaceable></option> <listitem>
gtester-specific argument.
</listitem> </varlistentry> </variablelist>
Since: 2.16
IMPORT_C int | g_test_run | ( | void | ) |
g_test_run:
Runs all tests under the toplevel suite which can be retrieved with g_test_get_root(). Similar to g_test_run_suite(), the test cases to be run are filtered according to test path arguments (-p <replaceable>testpath</replaceable>) as parsed by g_test_init(). g_test_run_suite() or g_test_run() may only be called once in a program.
Returns: 0 on success
Since: 2.16
IMPORT_C void | g_test_add_func | ( | const char * | testpath, |
void(*)(void) | test_func | |||
) |
g_test_add_func: : Slash-separated test case path name for the test. : The test function to invoke for this test.
Create a new test case, similar to g_test_create_case(). 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 .
Since: 2.16
IMPORT_C void | g_test_add_data_func | ( | const char * | testpath, |
gconstpointer | test_data, | |||
void(*)(gconstpointer) | test_func | |||
) |
g_test_add_data_func: : Slash-separated test case path name for the test. : Test data argument for the test function. : The test function to invoke for this test.
Create a new test case, similar to g_test_create_case(). 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 . The argument will be passed as first argument to .
Since: 2.16
IMPORT_C void | g_test_message | ( | const char * | format, |
... | ||||
) |
IMPORT_C void IMPORT_C void | g_test_bug_base | ( | const char * | uri_pattern | ) |
g_test_bug_base: : the base pattern for bug URIs
Specify the base URI for bug reports.
The base URI is used to construct bug report messages for g_test_message() when g_test_bug() 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 , or by replacing the special string 's' within if that is present.
Since: 2.16
IMPORT_C void | g_test_bug | ( | const char * | bug_uri_snippet | ) |
g_test_bug: : Bug specific bug tracker URI portion.
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 g_test_bug_base() and .
Since: 2.16
IMPORT_C void | g_test_timer_start | ( | void | ) |
g_test_timer_start:
Start a timing test. Call g_test_timer_elapsed() when the task is supposed to be done. Call this function again to restart the timer.
Since: 2.16
IMPORT_C double | g_test_timer_elapsed | ( | void | ) |
g_test_timer_elapsed:
Get the time since the last start of the timer with g_test_timer_start().
Returns: the time since the last start of the timer, as a double
Since: 2.16
IMPORT_C double | g_test_timer_last | ( | void | ) |
g_test_timer_last:
Report the last result of g_test_timer_elapsed().
Returns: the last result of g_test_timer_elapsed(), as a double
Since: 2.16
IMPORT_C void | g_test_queue_free | ( | gpointer | gfree_pointer | ) |
g_test_queue_free: : the pointer to be stored.
Enqueue a pointer to be released with g_free() during the next teardown phase. This is equivalent to calling g_test_queue_destroy() with a destroy callback of g_free().
Since: 2.16
IMPORT_C void | g_test_queue_destroy | ( | GDestroyNotify | destroy_func, |
gpointer | destroy_data | |||
) |
g_test_queue_destroy: : Destroy callback for teardown phase. : Destroy callback data.
This function enqueus a callback () 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 B() to be called before A() during teardown.
Since: 2.16
Enumerator | Value | Description |
---|---|---|
G_TEST_TRAP_SILENCE_STDOUT | 1 << 7 | |
G_TEST_TRAP_SILENCE_STDERR | 1 << 8 | |
G_TEST_TRAP_INHERIT_STDIN | 1 << 9 |
IMPORT_C gboolean | g_test_trap_fork | ( | guint64 | usec_timeout, |
GTestTrapFlags | test_trap_flags | |||
) |
g_test_trap_fork: : Timeout for the forked test in micro seconds. : Flags to modify forking behaviour.
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 .
The forking behavior can be configured with the GTestTrapFlags flags.
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.
|[ static void test_fork_patterns (void) { if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) { g_print ("some stdout text: somagic17\n"); g_printerr ("some stderr text: semagic43\n"); exit (0); / successful test run / } g_test_trap_assert_passed(); g_test_trap_assert_stdout ("*somagic17*"); g_test_trap_assert_stderr ("*semagic43*"); } ]|
This function is implemented only on Unix platforms.
Returns: TRUE for the forked child and FALSE for the executing parent process.
Since: 2.16
IMPORT_C gboolean | g_test_trap_has_passed | ( | void | ) |
g_test_trap_has_passed:
Check the result of the last g_test_trap_fork() call.
Returns: TRUE if the last forked child terminated successfully.
Since: 2.16
IMPORT_C gboolean | g_test_trap_reached_timeout | ( | void | ) |
g_test_trap_reached_timeout:
Check the result of the last g_test_trap_fork() call.
Returns: TRUE if the last forked child got killed due to a fork timeout.
Since: 2.16
IMPORT_C gint32 | g_test_rand_int | ( | void | ) |
g_test_rand_int:
Get a reproducible random integer number.
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.
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.
Returns: a random number from the seeded random number generator.
Since: 2.16
g_test_rand_int_range: : the minimum value returned by this function : the smallest value not to be returned by this function
Get a reproducible random integer number out of a specified range, see g_test_rand_int() for details on test case random numbers.
Returns: a number with <= number < .
Since: 2.16
IMPORT_C double | g_test_rand_double | ( | void | ) |
g_test_rand_double:
Get a reproducible random floating point number, see g_test_rand_int() for details on test case random numbers.
Returns: a random number from the seeded random number generator.
Since: 2.16
IMPORT_C double | g_test_rand_double_range | ( | double | range_start, |
double | range_end | |||
) |
g_test_rand_double_range: : the minimum value returned by this function : the minimum value not returned by this function
Get a reproducible random floating pointer number out of a specified range, see g_test_rand_int() for details on test case random numbers.
Returns: a number with <= number < .
Since: 2.16
IMPORT_C GTestCase * | g_test_create_case | ( | const char * | test_name, |
gsize | data_size, | |||
gconstpointer | test_data, | |||
void(*)(void) | data_setup, | |||
void(*)(void) | data_test, | |||
void(*)(void) | data_teardown | |||
) |
g_test_create_case: : the name for the test case : the size of the fixture data structure : test data argument for the test functions : the function to set up the fixture data : the actual test function : the function to teardown the fixture data
Create a new GTestCase, named , this API is fairly low level, calling g_test_add() or g_test_add_func() is preferable. When this test is executed, a fixture structure of size will be allocated and filled with 0s. Then data_setup() is called to initialize the fixture. After fixture setup, the actual test function data_test() is called. Once the test run completed, the fixture structure is torn down by calling data_teardown() and after that the memory is released.
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, g_test_create_case() will be called with the same fixture, but varying and arguments.
Returns: a newly allocated GTestCase.
Since: 2.16
IMPORT_C GTestSuite * | g_test_create_suite | ( | const char * | suite_name | ) |
g_test_create_suite: : a name for the suite
Create a new test suite with the name .
Returns: A newly allocated GTestSuite instance.
Since: 2.16
IMPORT_C GTestSuite * | g_test_get_root | ( | void | ) |
g_test_get_root:
Get the toplevel test suite for the test path API.
Returns: the toplevel GTestSuite
Since: 2.16
IMPORT_C void | g_test_suite_add | ( | GTestSuite * | suite, |
GTestCase * | test_case | |||
) |
IMPORT_C void | g_test_suite_add_suite | ( | GTestSuite * | suite, |
GTestSuite * | nestedsuite | |||
) |
IMPORT_C int | g_test_run_suite | ( | GTestSuite * | suite | ) |
g_test_run_suite: : a GTestSuite
Execute the tests within and all nested #GTestSuites. The test suites to be executed are filtered according to test path arguments (-p <replaceable>testpath</replaceable>) as parsed by g_test_init(). g_test_run_suite() or g_test_run() may only be called once in a program.
Returns: 0 on success
Since: 2.16
IMPORT_C void | g_test_trap_assertions | ( | const char * | domain, |
const char * | file, | |||
int | line, | |||
const char * | func, | |||
guint64 | assertion_flags, | |||
const char * | pattern | |||
) |
IMPORT_C void | g_assertion_message | ( | const char * | domain, |
const char * | file, | |||
int | line, | |||
const char * | func, | |||
const char * | message | |||
) |
IMPORT_C void | g_assertion_message_expr | ( | const char * | domain, |
const char * | file, | |||
int | line, | |||
const char * | func, | |||
const char * | expr | |||
) |
IMPORT_C void | g_assertion_message_cmpstr | ( | const char * | domain, |
const char * | file, | |||
int | line, | |||
const char * | func, | |||
const char * | expr, | |||
const char * | arg1, | |||
const char * | cmp, | |||
const char * | arg2 | |||
) |
IMPORT_C void | g_assertion_message_cmpnum | ( | const char * | domain, |
const char * | file, | |||
int | line, | |||
const char * | func, | |||
const char * | expr, | |||
long double | arg1, | |||
const char * | cmp, | |||
long double | arg2, | |||
char | numtype | |||
) |
IMPORT_C void | g_assertion_message_error | ( | const char * | domain, |
const char * | file, | |||
int | line, | |||
const char * | func, | |||
const char * | expr, | |||
GError * | error, | |||
GQuark | error_domain, | |||
int | error_code | |||
) |
IMPORT_C void | g_test_add_vtable | ( | const char * | testpath, |
gsize | data_size, | |||
gconstpointer | test_data, | |||
void(*)(void) | data_setup, | |||
void(*)(void) | data_test, | |||
void(*)(void) | data_teardown | |||
) |
GLIB_VAR const GTestConfig *const | g_test_config_vars |
IMPORT_C const GTestConfig *const * | _g_test_config_vars | ( | void | ) |
typedef struct GTestLogMsg | GTestLogMsg |
typedef struct GTestLogBuffer | GTestLogBuffer |
IMPORT_C const char * | g_test_log_type_name | ( | GTestLogType | log_type | ) |
IMPORT_C GTestLogBuffer * | g_test_log_buffer_new | ( | void | ) |
g_test_log_buffer_new:
Internal function for gtester to decode test log messages, no ABI guarantees provided.
IMPORT_C void | g_test_log_buffer_free | ( | GTestLogBuffer * | tbuffer | ) |
g_test_log_buffer_free
Internal function for gtester to free test log messages, no ABI guarantees provided.
IMPORT_C void | g_test_log_buffer_push | ( | GTestLogBuffer * | tbuffer, |
guint | n_bytes, | |||
const guint8 * | bytes | |||
) |
g_test_log_buffer_push
Internal function for gtester to decode test log messages, no ABI guarantees provided.
IMPORT_C GTestLogMsg * | g_test_log_buffer_pop | ( | GTestLogBuffer * | tbuffer | ) |
g_test_log_buffer_pop:
Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
IMPORT_C void | g_test_log_msg_free | ( | GTestLogMsg * | tmsg | ) |
g_test_log_msg_free:
Internal function for gtester to free test log messages, no ABI guarantees provided.