{"id":22892445,"url":"https://github.com/ctronp/mct","last_synced_at":"2025-03-31T22:10:39.007Z","repository":{"id":45525085,"uuid":"513769864","full_name":"ctronp/MCT","owner":"ctronp","description":"Micro C Test, a single header library for testing.","archived":false,"fork":false,"pushed_at":"2023-01-05T19:20:44.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T01:17:26.814Z","etag":null,"topics":["c","c-testing","ctest","testing"],"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/ctronp.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":"2022-07-14T05:22:09.000Z","updated_at":"2023-08-19T13:04:01.000Z","dependencies_parsed_at":"2023-02-04T11:30:28.850Z","dependency_job_id":null,"html_url":"https://github.com/ctronp/MCT","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/ctronp%2FMCT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctronp%2FMCT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctronp%2FMCT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctronp%2FMCT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctronp","download_url":"https://codeload.github.com/ctronp/MCT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246547366,"owners_count":20794970,"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","c-testing","ctest","testing"],"created_at":"2024-12-13T23:00:02.913Z","updated_at":"2025-03-31T22:10:38.982Z","avatar_url":"https://github.com/ctronp.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MCT\n\nMCT (Micro C Test) is a single header library for fast and efficient testing.\n\nThe purpose of creating this library as a single header is to easily integrate it with CMake or any other compilation\nmethod.\n\n## Usage\n\njust copy the [MCT.h](/MCT.h) file to the project in which you want to use it.\n\n## Example\n\n```C\n#include \"MCT.h\"\n\n// We call the macro to start the tests\nSTART_TESTING(NULL){\n    printf(\"Only run on first execution.\");\n}\n\n// The code between START_TESTING and TEST\n// will be evaluated countless times, no\n// code should be outside the braces.\n\nTEST(test name, test description){\n// Code for the first test\nASSERT(1)\nASSERT_EQ_INT(1, 1)\nASSERT_EQ_DBL(1.0, 1.0)\nASSERT_EQ_STR(\"test\", \"test\")\nASSERT_EQ_PTR(NULL, NULL)\n}\n\n\n\nTEST(failed test, description of failed test){\n// Code for the second test\nASSERT(0)\nASSERT_EQ_INT(1, 2)\nASSERT_EQ_DBL(1.0, 2.0)\nASSERT_EQ_STR(\"test\", \"test2\")\nASSERT_EQ_PTR(NULL, \"test\")\n}\n\nEND_TESTING\n```\n\na longer example can be found [here](https://github.com/ctronp/EfficientDataStructures/tree/dev/tests)\nor [here](/pass_test.c)\n\n## Macros\n\n### START_TESTING\n\nThis macro generates the basic structure for test execution.\n\nIt receives as argument a function ```void (*fun)()``` which will be executed prior to each test, in case it is not\nrequired, set NULL.\n\nthis macro must be used in conjunction with 2 curly brackets that will contain the code to be executed prior to\nall tests.\n\n#### Example\n\n```C\nSTART_TESTING(NULL) { printf(\"starting tests\"); }\n```\n\n### TEST\n\nThis macro generates a test. The macro receives 2 parameters, the first is the name the test takes, the second is the\ndescription of the test.\n\nThis macro must be used in conjunction with 2 curly brackets that will contain the code to be executed.\n\na TEST can only be placed after START_TESTING or another TEST.\n\n### ASSERT_*\n\nMultiple ```ASSERT``` macros were created that work to validate inside a [TEST](#TEST), in case they fail they will stop\nthe execution of the test, print the error to the stdout, and continue with the next TEST in case it exists.\n\n#### Example\n\n```C\nTEST(test name, test description){\n// Code for the first test\nASSERT(1)\nASSERT_EQ_INT(1, 1)\nASSERT_EQ_DBL(1.0, 1.0)\nASSERT_EQ_STR(\"test\", \"test\")\nASSERT_EQ_PTR(NULL, NULL)\n}\n```\n\n### END_TESTING\n\nThis macro prints the final results and ends the program execution.\n\nin case 1 or more tests have failed the program will close with code 1.\n\nin case there is no TEST the program will close with code 1.\n\nin case there is at least 1 TEST and no test has failed, the program will close with code 0.\n\n## Include in CMake\n\ncan be included directly as an ``add_executable`` file or as an ``INTERFACE`` library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctronp%2Fmct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctronp%2Fmct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctronp%2Fmct/lists"}