Criterion
The Criterion testing framework is available in its Github repository. Reference for the Criterion API can be found here: https://criterion.readthedocs.io/en/master/intro.html.
Basic Setup
int add(int a, int b) {
return a + b;
}
int add(int a, int b) {
return a + b;
}
#include <criterion/criterion.h>
int add(int, int);
Test(add_test, should_add_integers, .description = "should add integers") {
int a = 1;
int b = 1;
int expected = 2;
cr_assert_eq(expected, add(a, b), "add(%d, %d) == %d", a, b, expected);
}
#include <criterion/criterion.h>
int add(int, int);
Test(add_test, should_add_integers, .description = "should add integers") {
int a = 1;
int b = 1;
int expected = 2;
cr_assert_eq(expected, add(a, b), "add(%d, %d) == %d", a, b, expected);
}
Assertions
TBD
Assertions reference can be found in the Criterion documentation.
- assert vs except
- messages