TestCase


Description:

public TestCase (string test_name, TestFunc data_setup, TestFunc data_func, TestFunc data_teardown, size_t data_size = 0)

Create a new TestCase, named test_name, this API is fairly low level, calling g_test_add or add_func is preferable.

When this test is executed, a fixture structure of size data_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, TestCase will be called with the same fixture, but varying test_name and data_test arguments.

Parameters:

test_name

the name for the test case

data_setup

the function to set up the fixture data

data_teardown

the function to teardown the fixture data

data_size

the size of the fixture data structure

data_test

the actual test function

test_data

test data argument for the test functions

Returns:

a newly allocated TestCase.