1
0
Fork
You've already forked sunit
0
No description
  • C 93.6%
  • CMake 6.4%
Find a file
2026年05月06日 19:23:21 +02:00
include Revamp framework AGAIN 2026年04月13日 20:13:59 +02:00
test Revamp framework AGAIN 2026年04月13日 20:13:59 +02:00
.clang-format Revamp framework AGAIN 2026年04月13日 20:13:59 +02:00
.clang-tidy Revamp framework AGAIN 2026年04月13日 20:13:59 +02:00
.gitignore Revamp framework AGAIN 2026年04月13日 20:13:59 +02:00
CMakeLists.txt Add CMake switch for testing of framework 2026年05月06日 19:23:21 +02:00
README.md Update README 2024年11月15日 17:44:39 +01:00

sudo's unit - sunit

An extremly minimal unit testing framework for C.

How to use

There are two different types of test cases: Facts and Theories.

A fact passes if it returns true, else it fails.

Fact example:

#include <math.h>
#include "test.h"
FACT(NAN_not_equal_NAN)
{
 return NAN != NAN;
}
FIXTURE_BEGIN
RUN_FACT(NAN_not_equal_NAN);
FIXTURE_END

A theory gets passed a parameter and executed for each dataset. It passes only if all executions return true, else it fails.

Theory example:

#include "test.h"
// Function under test
bool is_odd(int x)
{
 return (x % 2) != 0;
}
THEORY(is_odd_returnes_true_on_odd, x)
{
 return is_odd(x);
}
THEORY(is_odd_returns_false_on_even, x)
{
 return !is_odd(x);
}
FIXTURE_BEGIN
RUN_THEORY(is_odd_returnes_true_on_odd, int, 1, 7, 57425681, 65437249, -5243);
RUN_THEORY(is_odd_returns_false_on_even, int, 2, 4, -653248, 430412);
FIXTURE_END