{"id":24956221,"url":"https://github.com/hadichahine/cest","last_synced_at":"2025-03-28T20:17:01.445Z","repository":{"id":128675330,"uuid":"195657108","full_name":"hadichahine/cest","owner":"hadichahine","description":"A traditional unit testing library for C.","archived":false,"fork":false,"pushed_at":"2020-09-15T04:19:07.000Z","size":117,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-03T06:32:43.942Z","etag":null,"topics":["c","cest","tdd","test-driven-development","testing","unit-testing"],"latest_commit_sha":null,"homepage":null,"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/hadichahine.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-07-07T13:53:09.000Z","updated_at":"2022-01-18T19:33:23.000Z","dependencies_parsed_at":"2023-03-13T11:28:45.877Z","dependency_job_id":null,"html_url":"https://github.com/hadichahine/cest","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadichahine%2Fcest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadichahine%2Fcest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadichahine%2Fcest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadichahine%2Fcest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hadichahine","download_url":"https://codeload.github.com/hadichahine/cest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246093182,"owners_count":20722403,"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","cest","tdd","test-driven-development","testing","unit-testing"],"created_at":"2025-02-03T06:28:09.418Z","updated_at":"2025-03-28T20:17:01.439Z","avatar_url":"https://github.com/hadichahine.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cest\nA traditional unit testing library for C.\n\n[![cest's automated build and test.](https://travis-ci.com/hadichahine/cest.svg?branch=master)](https://travis-ci.com/hadichahine/cest)\n\ncest's current features:\n- Single test execution.\n- Test suite creation and execution.\n- Before suite startup and after finishing hooks.\n\n## Packages\n- [cest-git](https://aur.archlinux.org/packages/cest-git/) on AUR\n\n## Dependencies\n- **make**\n- **libc**\n\n## Developer Extra Dependencies\n- **gdb**\n- **valgrind**\n\n## Installation\n**cest** works for now only on **GNU/Linux** based operating systems.\n```\nuser@machine$ make\nuser@machine$ make check\nuser@machine$ make install INSTALL_DIR=/usr/\n```\n**INSTALL_DIR** is **/usr/** by default.\n\nAll executed make tasks should complete successfully. \n\n## Test Compilation\n- Compile against libcest.so.\n```\nuser@machine$ gcc test.c -lcest -o CestSampleTest\n```\n## Using Test Suite Constructor\n\nThe test suite conctructor is in its early stages with extremely small and basic features. Using the API is the way to go if you're going to use test hooks.\n```\n#include \u003ccest/create_test_suite.h\u003e\n\nSTART_TEST_SUITE(\"Test that test is test\")\n\nint pow(int x){\n\treturn x*x;\n}\n\nTEST(\"Test that pow(0) is zero\",(Assert *assert){\n    Assert_assertTrue(assert,pow(0) == 0);\n});\n\nTEST(\"Test that pow(2) == 4\",(Assert *assert){\n    Assert_assertTrue(assert,pow(2) == 4);\n});\n\nEND_TEST_SUITE\n```\n\n## Using the Inner API\n### Create and execute a single test\n- Include **cest**'s test header.\n```C\n#include \u003ccest/cutest.h\u003e\n```\n\n- Create test function globally.\n```C\nvoid test_function(Assert *assert){\n  Assert_assertTrue(assert, 1+1 == 2);\n}\n```\n- Create single test.\n```C\nCUTest *test = CUTest_create(\"Test name is here\", test_function);\n```\n- Execute test.\n```C\nCUTest_execute(test);\nCUTest_didTestPass(test); //returns 1 if test passed; 0 otherwise.\n```\n### Create and execute a test suite\n- Include **cest**'s test suite header.\n```C\n#include \u003ccest/cutestsuite.h\u003e\n```\n\n- Create test suite.\n```C\nCUTestSuite *testSuite = CUTestSuite_create(\"Passing Test Suite\");\nCUTestSuite_addTest(testSuite, \"passing test\", passingTest);\n```\n\n- Execute test suite.\n```C\nCUTestSuite_execute(testSuite);\nCUTestSuite_didPass(testSuite); //returns 1 if test passed; 0 otherwise.\n```\n\n### Add Before Startup and After Finishing Hooks\n```C\nvoid beforeStartHook() {\n  // Setup suite\n}\n\nvoid afterFinishtHook() {\n  // Teardown suite\n}\n\nCUTestSuite_runHookBeforeStartingSuite(testSuite, beforeStartHook);\nCUTestSuite_runHookAfterFinishingSuite(testSuite, afterFinishHook);\n```\n\n### Test \u0026 Test Suite Destruction\nTo Destroy test suite:\n```C\nCUTestSuite_destroy(testSuite);\n```\nsimilarly for any destroying a lone test:\n```C\nCUTest_destroy(test);\n```\nTest Suites (or single tests) are better destroyed if execution of the test suite (or test) has finished and it's not used again.\n\n## Test Debugging\n\nTo debug any test from the test suite use the following command:\n```C\n[user@machine ~]$ make test-debug TEST=test_name\n```\nThis command launches gdb on the target test.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhadichahine%2Fcest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhadichahine%2Fcest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhadichahine%2Fcest/lists"}