https://github.com/codeplea/minctest
tiny unit testing framework for ANSI C
https://github.com/codeplea/minctest
Last synced: about 2 months ago
JSON representation
tiny unit testing framework for ANSI C
- Host: GitHub
- URL: https://github.com/codeplea/minctest
- Owner: codeplea
- License: zlib
- Created: 2015-09-24T04:41:04.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2021-03-03T22:51:32.000Z (over 4 years ago)
- Last Synced: 2025-04-22T11:18:02.381Z (2 months ago)
- Language: C
- Homepage: https://codeplea.com/minctest
- Size: 10.7 KB
- Stars: 55
- Watchers: 9
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minctest
Minctest is a very minimal unit-testing "framework" written in ANSI C and
implemented in a single header file. It's handy when you want some real simple
unit tests for a small project.Basically, it implements assertion and equal functions. It'll track and time
how many tests pass and fail. Failed tests will also display which line the
failing test code was on.There is a [Node.js port here](https://github.com/codeplea/minctest-node) and a [Lua port here.](https://github.com/codeplea/minctest-lua)
## Features
- **C99 with no dependencies**.
- Single header file.
- Reports file and line number for failed assertions.
- Reports run time for each test.
- Tests continue even after an assertion fails.
- Has assertion for checking float equality.
- Released under the zlib license - free for nearly any use.## Example
#include "minctest.h"
void test1() {
lok('a' == 'a');
}void test2() {
lequal(5, 5);
lfequal(5.5, 5.5);
lsequal("abc", "abc");
}int main(int argc, char *argv[])
{
lrun("test1", test1);
lrun("test2", test2);
lresults();
return lfails != 0;
}That produces the following output:
test1:
-- pass: 1 fail: 0 time: 12ms
test2:
-- pass: 3 fail: 0 time: 0ms
ALL TESTS PASSED (4/4)## Hints
All functions/variables start with the letter 'l'.## Users
Minctest is used in almost all of my C projects, including:
* [Tulip Indicators - Financial Technical Analysis Indicators](https://tulipindicators.org)
* [TinyExpr - Math Expression Evaluation Library](https://codeplea.com/tinyexpr)
* [Genann - Neural Network Library](https://codeplea.com/genann)You can check those out to see how Minctest is used in practice.
If you're using Minctest in your project, let me know. I could add a link back.