diff options
author | Pawel Szewczyk <p.szewczyk@samsung.com> | 2015-09-14 12:52:12 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-09-23 16:42:11 +0200 |
commit | da22fa6c2435c8421817292e5ca1269c7f4e4959 (patch) | |
tree | 68620f0e0c6b517212c8942dad4b8abca994d4b8 /tests/test_group_fixtures.c | |
parent | cc3386b4ce502e532686a6ec0c56af362cb33e86 (diff) | |
download | cmocka-da22fa6c2435c8421817292e5ca1269c7f4e4959.tar.gz cmocka-da22fa6c2435c8421817292e5ca1269c7f4e4959.tar.xz cmocka-da22fa6c2435c8421817292e5ca1269c7f4e4959.zip |
cmocka: Allow to pass initial data to test cases
Sometimes multiple test cases share the same test function, running it
on different data. To pass this data to test functions we must define
setup function for each data set. It's not very convienient when there
are many states to test.
This commit introduce more elegant way to pass data to tests. The
initial_state field of CMUnitTest structure can be defined by user.
It will be either passed to setup function, which makes any preparation
needed, or it will be passed directly to test function when setup func is
NULL.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Diffstat (limited to 'tests/test_group_fixtures.c')
-rw-r--r-- | tests/test_group_fixtures.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/test_group_fixtures.c b/tests/test_group_fixtures.c index 09f39b1..64f0ab7 100644 --- a/tests/test_group_fixtures.c +++ b/tests/test_group_fixtures.c @@ -39,9 +39,11 @@ static void test_value_range(void **state) } int main(void) { + int prestate = 1337; const struct CMUnitTest tests[] = { cmocka_unit_test(test_value_equal), cmocka_unit_test(test_value_range), + cmocka_unit_test_prestate(test_value_equal, &prestate), }; return cmocka_run_group_tests(tests, group_setup, group_teardown); |