You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Minunit is a minimal unit testing framework for C/C++ self-contained in a
single header file.
It provides a way to define and configure test suites and a few handy assertion
types. It reports the summary of the number of tests run, number of assertions
and time elapsed.
Check out minunit_example.c to see a complete example. Compile with something
like:
gcc minunit_example.c -lrt -lm -o minunit_example
Don't forget to add -lrt for the timer and -lm for linking the function fabs
used in mu_assert_double_eq.
Setup and teardown functions
One can define setup and teardown functions and configure the test suite to run
them by using the macro MU_SUITE_CONFIGURE with within a MU_TEST_SUITE
declaration.
Assertion types
mu_check(condition): will pass if the condition is evaluated to true, otherwise
it will show the condition as the error message
mu_fail(message): will fail and show the message
mu_assert(condition, message): will pass if the condition is true, otherwise it
will show the failed condition and the message
mu_assert_int_eq(expected, result): it will pass if the two numbers are
equal or show their values as the error message
mu_assert_double_eq(expected, result): it will pass if the two values
are almost equal or show their values as the error message. The value of
MINUNIT_EPSILON sets the threshold to determine if the values are close enough.
mu_assert_string_eq(expected, resurt): it will pass if the two strings are equal.