{"id":24227554,"url":"https://github.com/mackenzie-high/unit_test_c","last_synced_at":"2025-03-04T06:14:33.356Z","repository":{"id":271537447,"uuid":"913746027","full_name":"Mackenzie-High/unit_test_c","owner":"Mackenzie-High","description":"A nano unit testing framework for  C","archived":false,"fork":false,"pushed_at":"2025-01-08T11:08:20.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T06:14:31.193Z","etag":null,"topics":["c","framework","minimalistic","unit-testing","unlicense"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mackenzie-High.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":"2025-01-08T09:21:13.000Z","updated_at":"2025-01-08T11:11:57.000Z","dependencies_parsed_at":"2025-01-08T11:43:01.105Z","dependency_job_id":null,"html_url":"https://github.com/Mackenzie-High/unit_test_c","commit_stats":null,"previous_names":["mackenzie-high/unit_test_c"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mackenzie-High%2Funit_test_c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mackenzie-High%2Funit_test_c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mackenzie-High%2Funit_test_c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mackenzie-High%2Funit_test_c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mackenzie-High","download_url":"https://codeload.github.com/Mackenzie-High/unit_test_c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241794137,"owners_count":20021192,"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","framework","minimalistic","unit-testing","unlicense"],"created_at":"2025-01-14T10:18:13.215Z","updated_at":"2025-03-04T06:14:33.336Z","avatar_url":"https://github.com/Mackenzie-High.png","language":"C","readme":"# unit_test_c\n\nProvides a [unit_test.h](src/unit_test.h) and [unit_test.c](src/unit_test.c) for use in unit-testing of C programs.\n\n## Installation\n\nSimply download the two files into your project.\n+ [unit_test.h](src/unit_test.h)\n+ [unit_test.c](src/unit_test.c)\n\n## Example\n\nThis repo contains an example of unit-testing a hello world application that contains a fibonacci number function.\n\nThe [example.c](src/example.c) defines the entrypoint, and for simplicity of the example, the `fib` function too.\n\nThe [example.h](src/example.h) declares the `fib` function and the `declare_tests` function.\n\nThe [test_example.c](tests/test_example.c) defines the unit tests cases themselves.\n\n### Hello World\n\nFirst, let us build and run the program **without unit tests**.\n\n```\nrm -rf build/*.o build/example build/test_example\nmackenzie@caprica: make \u0026\u003e build.log\nmackenzie@caprica: ./build/example\nHello World!\nfib(0) = 0\nfib(1) = 1\nfib(2) = 1\nfib(3) = 2\nfib(4) = 3\nfib(5) = 5\nmackenzie@caprica:\n```\n\n### Run Unit Tests\n\n```\nmackenzie@caprica: ./build/test_example --test --all\n----------------------------- TEST CASE -----------------------------\nSuite: ExampleSuite\nName: test_basecase_0\nDo work to before the test.\nDo work to after the test.\nElapsed Time: 0.0000 seconds\nResult: PASS\n--------------------------- END TEST CASE ---------------------------\n\n\n----------------------------- TEST CASE -----------------------------\nSuite: ExampleSuite\nName: test_basecase_1\nDo work to before the test.\nDo work to after the test.\nElapsed Time: 0.0000 seconds\nResult: PASS\n--------------------------- END TEST CASE ---------------------------\n\n\n----------------------------- TEST CASE -----------------------------\nSuite: ExampleSuite\nName: test_basecase_0\nElapsed Time: 0.0000 seconds\nResult: PASS\n--------------------------- END TEST CASE ---------------------------\n\n\n-------------------------- RESULTS SUMMARY --------------------------\nPassed Tests: 3\nFailed Tests: 0\nTotal  Tests: 3\nElapsed Time: 0.0000 seconds\n------------------------------ PASSED -------------------------------\nmackenzie@caprica:\n```\n\n### Other Options\n\n```\nmackenzie@caprica: ./build/test_example --test -h\nUnit Test Help:\n    --test:                        Activate the unit test runner.\n    --all, -a:                     Enable all unit test suites and test cases.\n    --enable-suite  \u003csuite\u003e:       Enable the named unit test suite.\n    --disable-suite \u003csuite\u003e:       Disable the named unit test suite.\n    --enable-case  \u003csuite\u003e \u003cname\u003e: Enable the named unit test case.\n    --disable-case \u003csuite\u003e \u003cname\u003e: Disable the named unit test case.\n    --help, -h:                    Print this help message.\nmackenzie@caprica:\n```\n\n## Assertion Macros\n\n| Macro Signature                                     | Description                                                                             |\n|-----------------------------------------------------|-----------------------------------------------------------------------------------------|\n| `fail(...)`                                         | Marks a test as failed and reports the file and line number of the failure.             |\n| `assertTrue(CONDITION, ...)`                        | Fails the test if the CONDITION evaluates to false.                                     |\n| `assertFalse(CONDITION, ...)`                       | Fails the test if the CONDITION evaluates to true.                                      |\n| `assertImplies(LEFT, RIGHT, ...)`                   | Fails the test if LEFT is true and RIGHT is false.                                      |\n| `assertEqual(EXPECTED, ACTUAL, ...)`                | Fails the test if EXPECTED is not equal to ACTUAL.                                      |\n| `assertNotEqual(EXPECTED, ACTUAL, ...)`             | Fails the test if EXPECTED is equal to ACTUAL.                                          |\n| `assertEquals(EXPECTED, ACTUAL, ...)`               | Fails the test if EXPECTED is not equal to ACTUAL (alias for assertEqual).              |\n| `assertNotEquals(EXPECTED, ACTUAL, ...)`            | Fails the test if EXPECTED is equal to ACTUAL (alias for assertNotEqual).               |\n| `assertLess(LEFT, RIGHT, ...)`                      | Fails the test if LEFT is not less than RIGHT.                                          |\n| `assertLessEqual(LEFT, RIGHT, ...)`                 | Fails the test if LEFT is greater than RIGHT.                                           |\n| `assertGreater(LEFT, RIGHT, ...)`                   | Fails the test if LEFT is not greater than RIGHT.                                       |\n| `assertGreaterEqual(LEFT, RIGHT, ...)`              | Fails the test if LEFT is less than RIGHT.                                              |\n| `assertNull(VALUE, ...)`                            | Fails the test if VALUE is not NULL.                                                    |\n| `assertNotNull(VALUE, ...)`                         | Fails the test if VALUE is NULL.                                                        |\n| `assertStrEqual(EXPECTED, ACTUAL, ...)`             | Fails the test if the strings EXPECTED and ACTUAL are not equal.                        |\n| `assertStrNotEqual(EXPECTED, ACTUAL, ...)`          | Fails the test if the strings EXPECTED and ACTUAL are equal.                            |\n| `assertStrnEqual(EXPECTED, ACTUAL, LENGTH, ...)`    | Fails the test if the first LENGTH characters of EXPECTED and ACTUAL are not equal.     |\n| `assertStrnNotEqual(EXPECTED, ACTUAL, LENGTH, ...)` | Fails the test if the first LENGTH characters of EXPECTED and ACTUAL are equal.         |\n| `assertMemEqual(EXPECTED, ACTUAL, LENGTH, ...)`     | Fails the test if the memory blocks EXPECTED and ACTUAL are not equal for LENGTH bytes. |\n| `assertMemNotEqual(EXPECTED, ACTUAL, LENGTH, ...)`  | Fails the test if the memory blocks EXPECTED and ACTUAL are equal for LENGTH bytes.     |\n\nThe `...` varadic arguments are for passing in arguments to `printf` in case of test failure.\nThe first argument is the format specified, and the rest are the substitutions thereto.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmackenzie-high%2Funit_test_c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmackenzie-high%2Funit_test_c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmackenzie-high%2Funit_test_c/lists"}