Minimalist C Unit Testing Framework inspired by Jest and Gest.
Cest is a lightweight, header-only testing framework for C and related languages. It brings the expressive syntax of modern JavaScript and Go testing tools to C-family languages.
| Language | Extension | Compiler | Full Support |
|---|---|---|---|
| C | .c |
gcc, clang |
Yes |
| C++ | .cpp |
g++, clang++ |
Yes |
| Objective-C | .m |
clang -x objective-c |
Yes |
| Objective-C++ | .mm |
clang++ -x objective-c++ |
Yes |
| Language | Versions |
|---|---|
| C | C11, C17, C23 |
| C++ | C++17, C++20, C++23 |
| ObjC | ARC & non-ARC |
#include "cest.h"
int main() {
describe("Math Suite", {
it("sums numbers correctly", {
expect(1 + 1).toEqual(2);
});
});
return cest_result();
}gcc -std=c11 -o test test.c
./test#include "cest.h"
#include <string>
int main() {
describe("String Suite", {
it("compares strings", {
std::string s = "hello";
expect(s).toEqual("hello");
});
});
return cest_result();
}g++ -std=c++11 -o test test.cpp
./test#import "cest.h"
int main() {
describe("ObjC Suite", {
it("works with id", {
id obj = (id)0x1234;
expect(obj).toBeTruthy();
});
});
return cest_result();
}clang -x objective-c -o test test.m -lobjc
./testSetup and teardown code for tests:
void setup() { /* initialize */ }
void teardown() { /* cleanup */ }
beforeAll(setup);
afterAll(teardown);
describe("Database Tests", {
beforeEach(setup);
afterEach(teardown);
it("connects", {
expect(connect_db()).toBeTruthy();
});
});Simple performance measurement:
describe("Performance", {
bench("string operations", {
char buffer[100];
sprintf(buffer, "test %d", 42);
});
});Output:
● Performance
⚡ string operations: 0.000015s total, 0.000000s avg
Run specific tests from command line:
./test "Math" # Run only tests containing "Math"
./test # Run all tests- Header-Only: Just include
cest.hin your project. - Multi-Language: Native support for C, C++, Objective-C, and Objective-C++.
- Modern Language Support: C11/C17/C23, C++17/C++20/C++23, ObjC with ARC.
- No Dependencies: Zero external libraries (not even
-lm). - Modern Syntax: Uses
describe,it, andexpectfor readable tests. - Colorized Output: Instant visual feedback in your terminal.
- Type-Safe: Uses
_Generic(C11) or function overloading (C++) for automatic type handling. - Multi-file Support: Compile multiple
.ctest files and Cest unifies results. - Auto Grouping: Use
describe_file()to automatically group tests by source file. - Hooks Support:
beforeAll,afterAll,beforeEach,afterEachfor setup/cleanup. - Built-in Benchmarking: Simple performance measurement with
benchmacro. - Sanitizer Compatible: Works seamlessly with ASan, TSan, MSan.
- Clean Output: Automatic compiler warning suppression.
| Matcher | Description |
|---|---|
toBe(x) / toEqual(x) |
Checks value equality or identity. |
toBeTruthy() |
Checks if the value is "truthy". |
toBeFalsy() |
Checks if the value is "falsy" or null. |
toBeNull() |
Checks if a pointer is NULL or nil. |
toBeGreaterThan(x) |
Checks if the value is greater than x. |
toBeLessThan(x) |
Checks if the value is less than x. |
toBeInRange(min, max) |
Checks if the value is within range. |
toContain(substring) |
Checks if a string contains a sub-string. |
toStartWith(prefix) |
Checks if a string starts with prefix. |
toEndWith(suffix) |
Checks if a string ends with suffix. |
toBeCloseTo(val, prec) |
Compares doubles with specific precision. |
toEqualArray(arr, len) |
Compares two memory regions. |
make # Build all examples to build/
make run # Build and run all examples
make clean # Clean build directoryDetailed documentation is available in multiple languages:
This project is licensed under the BSD-3 Clause License.


