{"id":50357726,"url":"https://github.com/cwyang/c2unit","last_synced_at":"2026-05-29T23:17:44.228Z","repository":{"id":875059,"uuid":"617034","full_name":"cwyang/c2unit","owner":"cwyang","description":"Yet another C unit testing framework, Chulwoong's CUnit","archived":false,"fork":false,"pushed_at":"2015-09-24T10:08:49.000Z","size":136,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-04-20T21:15:21.077Z","etag":null,"topics":["c","unittest"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"stephenlb/pubnub-pam","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cwyang.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-04-19T01:03:20.000Z","updated_at":"2015-09-24T10:08:50.000Z","dependencies_parsed_at":"2022-08-16T11:15:26.791Z","dependency_job_id":null,"html_url":"https://github.com/cwyang/c2unit","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/cwyang/c2unit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwyang%2Fc2unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwyang%2Fc2unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwyang%2Fc2unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwyang%2Fc2unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwyang","download_url":"https://codeload.github.com/cwyang/c2unit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwyang%2Fc2unit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33674744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","unittest"],"created_at":"2026-05-29T23:17:43.318Z","updated_at":"2026-05-29T23:17:44.212Z","avatar_url":"https://github.com/cwyang.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Welcome to c2unit, Chul-woong's CUnit\n\n* Introduction\n\nThis is yet another C unit testing framework.\nWhy bother? To meet exact my need:\n(1) I'm trying to convert a legacy software into managable one.\n    If I'm in starting fresh projects, I'd rather pick up 'check' or\n    other existing unit testing platform.\n    However, LEGACY SOFTWARE is the one I'm facing.\n(2) I need a view on how much portion of software is tested:\n    \"200 funcs of 300 are tested\"\n    \"1200 asserts of 1200 asserts are passed\"\n(3) I want to a embed total testsuite into executables.\n    In other words, I want my software to be able to self-test,\n    and it should be simple.\n    If your executable is a.out then:\n      $ a.out -t              # run all tests\n      $ a.out -t -p 2         # run tests T, where pri(T) \u003c= 2\n      $ a.out -t -P \"session\" # run all tests with path prefix \"session\"\n\nHope this helps me and you. \n   \n* How to Run\n\n$ make\n\nAfter make, you get following components:\n(1) c2unit.h -- main headerfile\n(2) libc2unit.a\n(3) firstlink.o\n\nThen you should build your binary with following sequences:\n$(LINKER) firstlink.o $(YOUR_OBJS) $(OTHER_LIBS) lilbc2unit.a\n\nThen try run the executable with tests!\n\n* Quick-Start\n\n (1) Situation\n\n Say your target function foo() resides in foo.c like:\n\n #include \u003cfoo.h\u003e\n \n int foo(int a, int b) {\n         return a + b;    \n }\n\n Then,\n\n\n (2) Instrument Original Source\n\n #include \u003cfoo.h\u003e\n\n #define C2UNIT_TEST_PATH   // optional.\n #include \"c2unit.h\"        // should be in include-path\n\n FUNC_BEGIN(foo, NORMAL)    // FUNC_BEGIN(func_name, func_level)\n int foo(int a, int b) {\n         return a + b;    \n }\n FUNC_END(foo)\n\n ...\n\n #include \"foo_test.c\"      // recommend to put at the end of foo.c\n\n Instrument original source file like the above.\n\n C2UNIT_TEST_PATH provides a way to group tests.\n When there is over thousands of tests and you may want to\n test only your working tests for a while. Then define\n C2UNIT_TEST_PATH to unique identifier and use the identifier\n in running test cases to designate test group.\n\n It is not mandatory to keep test code as a file included to \n the original source file. It's just my test-code grouping style.\n I looked the content of source directory and be glad when \n each of source code file has accompanying _test.c file.\n\n (3) Code tests\n\n foo_test.c:\n\n #include \"c2unit.h\"                       // if needed\n\n TEST(foo, 1, \"this is a test for foo()\")  // name, no, desc\n {\n         ok(foo(1,2) == 3);         /* or c2_assert(foo(1,2) == 3); */\n         ok(foo(2,5) == 7);         /* or  c2_assert(foo(2,5) == 7); */\n }\n TEST_END(foo, 1)                          // name, no\n\n TEST(foo, 2, \"another test for foo()\")\n {\n         ok(foo(0,0) == 0);\n }\n TEST_END(foo, 2)\n\n // name, no, desc, pri\n TEST_FUNC(foo, 3, \"priority 2 test for foo(), it takes a long time\")\n {\n         sleep(1000);\n         ok(foo(-1, 1) == 0);\n }\n TEST_END(foo, 3)\n\n A test function is a pair between TEST (or TEST_FUNC) and TEST_END.\n TEST, TEST_FUNC, and TEST_END macros need arguments: \n  - name: name of function to test\n  - no  : serial number of the test. \n  - desc: description of the test. It is showed in test-run results.\n  - pri : test priority. This is another mechansim for designating\n          a group of tests to run.\n Note that (name, no) pair should be unique in a source file.\n\n\n (4) Do code to call test-runner from main()\n\n test_run(argc, argv) function is provided to as entry point.\n So, if you want to run test codes, call it.\n As test_run() parses additional command line option, it would be\n convinient to pass argc and argv from main() to test_run().\n (refer example.c)\n\n Following options are supported:\n   -P \u003ctest_path_prefix\u003e   test path prefix\n   -p \u003ctest_priority\u003e      test priority (1~3)\n   -d                      dump test and function information and exit\n   -c                      dump core when assert fails\n   -v                      be verbose\n\n (5) Test, code, and repeat!\n\n                               20 April 2010\n                             - Chul-Woong Yang (cwyang at gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwyang%2Fc2unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwyang%2Fc2unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwyang%2Fc2unit/lists"}