{"id":15049437,"url":"https://github.com/kick1911/unitest","last_synced_at":"2025-09-09T15:44:05.890Z","repository":{"id":127378024,"uuid":"210950164","full_name":"Kick1911/unitest","owner":"Kick1911","description":"A unit testing framework for C. Written in 100% C89 ISO preprocessor code.","archived":false,"fork":false,"pushed_at":"2023-04-30T18:42:25.000Z","size":95,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T02:09:20.556Z","etag":null,"topics":["c89","cpreprocessor","unittest"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kick1911.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-25T22:14:55.000Z","updated_at":"2025-04-04T14:47:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"d13dad5c-1f65-41fe-b818-7c2df63d83fc","html_url":"https://github.com/Kick1911/unitest","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kick1911%2Funitest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kick1911%2Funitest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kick1911%2Funitest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kick1911%2Funitest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kick1911","download_url":"https://codeload.github.com/Kick1911/unitest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142906,"owners_count":21054671,"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":["c89","cpreprocessor","unittest"],"created_at":"2024-09-24T21:20:27.888Z","updated_at":"2025-04-10T02:10:09.053Z","avatar_url":"https://github.com/Kick1911.png","language":"C","readme":"![C/C++ CI](https://github.com/Kick1911/unitest/workflows/C/C++%20CI/badge.svg)\n\n# unitest\n\nA unit testing framework for C. Written in 100% C89 ISO preprocessor code.\n\n# Usage\nI have designed this library to be easy-to-use. No init function needed (though, I am considering adding one). A `T_CONCLUDE` is needed at the end for final report and returning an error code if need be.\n\n## Start testing\nYou can add all your code as the second parameter of the `TEST` macro.\n```C\nTEST(Integer tests,\n        long int a = 1 \u003c\u003c 31;\n        long int b = a*a;\n        T_ASSERT(1 == 1);\n        T_ASSERT_NUM(1, 1);\n        T_ASSERT_NUM(b, a*a);\n);\n```\nor simply call a function in the second parameter.\n\n## Setup\nA setup function can be added as follows:\n```C\nvoid setup(void** args);\nT_SETUP(\u0026setup);\n```\nThe function should receive `void**` and return `void`.\nBy default you can 10 pointers to `args`. This can be changed with the definition, `T_SETUP_RESULT_SIZE`.\nTo access `args` in your test, use `T_SETUP_RESULT`.\nTo stop running the setup function, simply:\n```C\nT_SETUP(0);\n```\n\n## Teardown\nYou are responsible for deallocating all the memory you put into `T_SETUP_RESULT`.\nThe prototype for the teardown function follows the setup function. Adding the function is also similar.\n\n## Test reporters\n### Spec\nThis is the default reporter.\n\nTODO: Add image\n### List\nTo enable this reporter, compile with `-DT_REPORTER_LIST=1` argument.\n\nTODO: Add image\n### Dot\nLooks like the python `unittest` reporter. To enable this reporter, compile with `-DT_REPORTER_DOT=1` argument.\n\nTODO: Add image\n\n## Test Suites\nTest suites are done as follows, but of course you may substitute the second arguments for functions if you want to.\n```C\nT_SUITE(Binary operations,\n    TEST(OR,\n        T_ASSERT_NUM(1 | 0, 1);\n    );\n    TEST(XOR,\n        T_ASSERT_NUM(1 ^ 0, 1);\n    );\n    TEST(AND,\n        T_ASSERT_NUM(1 \u0026 0, 0);\n    );\n    TEST(NOT,\n        T_ASSERT_NUM(!1, 0);\n    );\n    TEST(TWOs compliment,\n        T_ASSERT_NUM(~1, -2);\n    );\n);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkick1911%2Funitest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkick1911%2Funitest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkick1911%2Funitest/lists"}