Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zyga/libzt
libzt is a simple and robust unit test library for C
https://github.com/zyga/libzt
c robust testing too
Last synced: 2 days ago
JSON representation
libzt is a simple and robust unit test library for C
- Host: GitHub
- URL: https://github.com/zyga/libzt
- Owner: zyga
- License: lgpl-3.0
- Created: 2020-01-12T23:29:19.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-21T21:52:23.000Z (almost 3 years ago)
- Last Synced: 2024-04-16T03:39:43.449Z (7 months ago)
- Topics: c, robust, testing, too
- Language: C
- Size: 204 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![C CI](https://github.com/zyga/libzt/workflows/C%20CI/badge.svg)
# libzt is an unit test library for C
libzt is a simple and robust unit test library for C.
## Features
- Robust, allowing you to focus on your code.
- Simple and small, making it quick to learn and use.
- Doesn't use dynamic memory allocation, reducing error handling.
- Equipped with useful helpers for writing test cases.
- Portable and supported on Linux, MacOS, Windows and DOS.
- Documented and fully coverage and integration tested.## Example
```
#include
#includestatic const char *greeting(void) {
return "hello there";
}static void test_smoke(zt_t t) {
zt_check(t, ZT_TRUE(2 + 2 == 4));
zt_check(t, ZT_CMP_INT(2 + 2, ==, 4));
zt_check(t, ZT_CMP_STR(greeting(), ==, "hello there"));
}static void test_writing_to_tmpfile(zt_t t) {
FILE *f = tmpfile();
zt_assert(t, ZT_NOT_NULL(f)); // stops test on failure
zt_check(t, ZT_CMP_INT(fprintf(f, "%s", greeting()), >, 0);
zt_check(t, ZT_CMP_INT(ftell(f), ==, strlen(greeting()));
zt_check(t, ZT_CMP_INT(fclose(f), ==, 0);
}static void test_suite(zt_visitor v) {
ZT_VISIT_TEST(v, test_smoke);
ZT_VISIT_TEST(v, test_writing_to_tmpfile);
}int main(int argc, char **argv, char **envp) {
return zt_main(argc, argv, envp, test_suite);
}
```