Reputation: 31
I'd like to write a test in cmocka and run it few times with different parameters each time (so I could test different input cases).
Something like Python's decorators @parameterized.parameters
.
There are ways I can think of, like:
The goal is better maintainability and scalability.
Simple example to a test to refactor:
Let's say I have a function bool is_even(int a)
and I want to test it. In the tests file:
static void test_returned_val_is_even(void **state) {
bool rc = is_even(2);
assert_true(rc);
}
p.s. Let's pretend the test does much more than just calling is_even :)
I was wandering what are other ways are out there and if there a methodology better than another and why :) Thanks in advance.
Upvotes: 3
Views: 597