2022-01-06 02:06:45 +01:00
|
|
|
#include "xtest.h"
|
2022-01-02 15:00:54 +01:00
|
|
|
#include "source.h"
|
2022-01-11 20:01:15 +01:00
|
|
|
#include "examples.h"
|
2022-01-02 15:00:54 +01:00
|
|
|
|
2022-01-11 20:01:15 +01:00
|
|
|
static void test_simple() {
|
2022-01-02 15:00:54 +01:00
|
|
|
xtest_expect_assertion_failure();
|
|
|
|
div(10, 0);
|
|
|
|
}
|
|
|
|
|
2022-01-11 20:01:15 +01:00
|
|
|
static void test_no_failure() {
|
|
|
|
div(10, 1);
|
2022-01-02 15:00:54 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:01:15 +01:00
|
|
|
static void test_no_failure_2() {
|
|
|
|
div(10, 2);
|
2022-01-02 15:00:54 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:01:15 +01:00
|
|
|
static void test_will_fail() {
|
2022-01-02 15:00:54 +01:00
|
|
|
xtest_expect_assertion_failure();
|
2022-01-11 20:01:15 +01:00
|
|
|
div(10, 1);
|
2022-01-02 15:00:54 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:01:15 +01:00
|
|
|
static void test_will_fail_2() {
|
|
|
|
div(10, 0);
|
2022-01-02 15:00:54 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:01:15 +01:00
|
|
|
static void test_other_failure() {
|
2022-01-02 15:00:54 +01:00
|
|
|
xtest_expect_assertion_failure();
|
|
|
|
xtest_assert(0);
|
|
|
|
div(10, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void example_expect_assertions() {
|
|
|
|
xtest_run(test_simple);
|
|
|
|
xtest_run(test_no_failure);
|
|
|
|
xtest_run(test_other_failure);
|
|
|
|
xtest_run(test_will_fail);
|
|
|
|
xtest_run(test_will_fail_2);
|
|
|
|
xtest_run(test_no_failure_2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef XTEST_ALL_EXAMPLES
|
2022-01-03 15:21:26 +01:00
|
|
|
XTEST_RUN_MAIN(example_expect_assertions)
|
|
|
|
#endif
|