{"id":13437007,"url":"https://github.com/ollelogdahl/ihct","last_synced_at":"2026-01-17T12:09:27.679Z","repository":{"id":55455241,"uuid":"321156704","full_name":"ollelogdahl/ihct","owner":"ollelogdahl","description":"'I Hate C Testing': A minimal testing framework for C.","archived":false,"fork":false,"pushed_at":"2021-03-31T22:24:13.000Z","size":323,"stargazers_count":155,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-27T21:48:57.544Z","etag":null,"topics":["c","test-automation"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ollelogdahl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-13T20:45:53.000Z","updated_at":"2024-10-23T19:03:16.000Z","dependencies_parsed_at":"2022-08-15T00:40:25.834Z","dependency_job_id":null,"html_url":"https://github.com/ollelogdahl/ihct","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollelogdahl%2Fihct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollelogdahl%2Fihct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollelogdahl%2Fihct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ollelogdahl%2Fihct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ollelogdahl","download_url":"https://codeload.github.com/ollelogdahl/ihct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244370724,"owners_count":20442297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","test-automation"],"created_at":"2024-07-31T03:00:53.695Z","updated_at":"2026-01-17T12:09:27.666Z","avatar_url":"https://github.com/ollelogdahl.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# ihct\n### 'I Hate C Testing': a minimal testing framework for C\nOlle Lögdahl, 13 December 2020\n\n![make](https://img.shields.io/github/workflow/status/ollelogdahl/ihct/build)\n![docs](https://img.shields.io/github/workflow/status/ollelogdahl/ihct/Doxygen?label=docs)\n![licence](https://img.shields.io/github/license/ollelogdahl/ihct)\n![issues](https://img.shields.io/github/issues-raw/ollelogdahl/ihct)\n![sloc](https://raw.githubusercontent.com/ollelogdahl/ihct/image-data/badge.svg)\n\n---\n\n**ihct** is a minimal C unit-testing framework. Intended for light unit testing, and focusing on development speed. \nLooking for more features, so please give any suggestions.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/ollelogdahl/ihct/blob/master/media.png\"\u003e\n\u003c/p\u003e\n\n## Installation \u0026 Usage\n\n#### See [documentation](https://ollelogdahl.github.io/ihct/)\n\nTo use this framework, simply include `ihct.h` in your project and link to the library. **Everything else happens automatically**.\nThe following code should get you started.\n\n```c\n#include \u003cihct.h\u003e\n\nIHCT_TEST(arithmetic_basic) {\n    int a = 13;\n    IHCT_ASSERT(a + 2 == 15);\n    IHCT_ASSERT(a * 2 == 26);\n}\nIHCT_TEST(string_basic) {\n    char *s1 = \"abba\";\n    IHCT_ASSERT_STR(s1, \"abba\");\n}\n\nint main(int argc, char **argv) {\n    return IHCT_RUN(argc, argv);\n}\n```\n\nTo fully install the library, run:\n```bash\nmkdir build\ncd build\ncmake .. \u0026\u0026 make -j4\nsudo make install\n```\n\nSee `ex.c` for an extended example. Note that tests are created as it's own executable, and therefore needs an entrypoint.\nThe example `ex.c` can be compiled and executed by running:\n```bash\nmkdir build\ncd build\ncmake .. \u0026\u0026 make -j4\n./example\n```\n\n---\n\n## Why?\nI have for a long time been stuck at unit testing in plain C. Many modern solutions use C++ as a test environment for C, but I wanted something\nmore lightweight, that i can quickly get up to speed with. I decided to write my own test framework with two things in mind: **development speed** \nand **minimalism**. To improve development speed, all test functions are automatically included into the runner, and the library interface is kept\nminimal. It requires no dependencies other than a POSIX compliant OS, and compiles on all GNU C99 POSIX compatible compilers. The library also \nimplements some safety to tests, catching fatal signals and hung functions.\n\n---\n\n## Features\n- Basic test units\n- Basic asserts\n- Automatic test loader\n- Catching fatal signals (SEGFAULTS etc.) in tests (no line number, but sets them as failed).\n- Catching hung tests (again, no line number).\n\nSelf tests can be run along with own tests by adding compiler flag `-DIHCT_SELF_TEST`. (This may be very redundant; just see it as more examples :-) )\n\nall macros (`IHCT_TEST`, `IHCT_ASSERT` etc.) can be shortened to remove the `IHCT` prefix, by defining `IHCT_SHORT` **before**\nincluding the header file.\n\n## Compatability notes\n - Since it requires `__attribute__((constructor))` it is not compilable with MSVC.\n - Since it uses pthreads and signals, it is POSIX (again, not sure it works with Windows).\n\n## Links\n\n- [Repository](https://github.com/ollelogdahl/ihct/)\n- For reporting errors, visit [Issue Tracker](https://github.com/ollelogdahl/ihct/issues)!\n- Related Projects:\n  - [cheat](https://github.com/Tuplanolla/cheat) by Guillermo \"Tordek\" Freschi and Sampsa \"Tuplanolla\" Kiiskinen\n\n## Licensing\n\nThis project, and all code it contains, is licensed under the *MIT License* and can be read [here](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Follelogdahl%2Fihct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Follelogdahl%2Fihct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Follelogdahl%2Fihct/lists"}