Unit testing framework in C, for C. The focus is on simplicity and flexibility, enough that on can edit the source files of the unit testing framework itself and bend it according to their needs.
Currently works and tested with only clang and gcc.
- basic assertion tests
- test execution in isolated child process
- multithreaded
- cross-platform
- works for C++ projects too
Names of all unit assertion macros are self-explanatory. Each macro's name reveals for what expression it will not fail. For example, PROVA_ASSERT_EQUAL_PTR(expected, actual) macro implies that the test won't fail if the pointer values expected and actual are equal in value.
Primitive assertions
PROVA_ASSERT_TRUE(expr)fails ifexpris falsePROVA_ASSERT_FALSE(expr)fails ifexpris truePROVA_ASSERT_NULL(ptr)fails ifptris not NULLPROVA_ASSERT_NOT_NULL(ptr)fails ifptris NULL
Generic assertions
Use with signed and unsigned integer types or data types comparable with common comparison operators in C like <, <= and >, >=. Pointers are cast to void* before comparison
PROVA_ASSERT_EQUAL_PTR(expected, actual)fails if pointer valuesexpectedandactualare not equalPROVA_ASSERT_NOT_EQUAL_PTR(expected, actual)fails if pointer valuesexpectedandactualare equalPROVA_ASSERT_EQUAL(expected, actual)fails if the valuesexpectedandactualare not equalPROVA_ASSERT_NOT_EQUAL(expected, actual)fails if the valuesexpectedandactualare equalPROVA_ASSERT_GREATER_THAN(threshold, actual)fails if the valueactualis not greater than thethresholdvaluePROVA_ASSERT_GREATER_EQUAL_THAN(threshould, actual)fails if the valueactualis smaller than thethresholdvaluePROVA_ASSERT_LESS_THAN(threshold, actual)fails if the valuethresholdis not greater than theactualvaluePROVA_ASSERT_LESS_EQUAL_THAN(threshold, actual)fails if the valueactualis greater than thethresholdvalue
Float assertions
The default value of PROVA_FLOAT_EPSILON is 10e-5.
PROVA_ASSERT_EQUAL_FLOAT(expected, actual)compares the floating valuesexpectedandactualwithin the error margin ofPROVA_FLOAT_EPSILONPROVA_ASSERT_NOT_EQUAL_FLOAT_WITHIN(delta, expected, actual)compares the floating valuesexpectedand within an error margin ofdelta
Memory assertions
PROVA_ASSERT_EQUAL_STRING(expected, actual)fails if the string values pointed to byexpectedandactualare not equal in bytesPROVA_ASSERT_EQUAL_STRING_LENGTH(expected, actual)fails if the string values pointed to byexpectedandactualare not equal in lengthPROVA_ASSERT_NOT_EQUAL_STRING(expected, actual)fails if the string values pointed to byexpectedandactualare equal in bytesPROVA_ASSERT_NOT_EQUAL_STRING_LENGTH(expected, actual)fails if the string values pointed to byexpectedandactualare equal in lengthPROVA_ASSERT_EQUAL_ARRAYS(expected, actual, n)fails if the contents of the arraysexpectedandactualare not equal.ndenotes the least of the sizes of both the arrays. Fails at the first mismatchPROVA_ASSERT_NOT_EQUAL_ARRAYS(expected, actual, n)fails if the contents of the arraysexpectedandactualare equal.ndenotes the least of the sizes of both the arrays. Fails at the first mismatchPROVA_ASSERT_EQUAL_MEMORY(expected, actual, n)fails if the contents of the memory blocksexpectedandactualare not equal.ndenotes the least of the sizes of both the arraysPROVA_ASSERT_NOT_EQUAL_MEMORY(expected, actual, n)fails if the contents of the memory blocksexpectedandactualare equal.ndenotes the least of the sizes of both the arrays
Apache License v2.0. Copyright (c) 2026 Abhigyan Kumar <314abh at gmail dot com>.