{"id":13420370,"url":"https://github.com/zorgnax/libtap","last_synced_at":"2025-12-28T16:07:26.524Z","repository":{"id":46622828,"uuid":"523814","full_name":"zorgnax/libtap","owner":"zorgnax","description":"Write tests in C","archived":false,"fork":false,"pushed_at":"2023-11-17T22:06:22.000Z","size":143,"stargazers_count":250,"open_issues_count":2,"forks_count":59,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-07-31T22:54:57.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zorgnax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2010-02-18T05:14:44.000Z","updated_at":"2024-06-28T03:01:41.000Z","dependencies_parsed_at":"2023-11-17T23:56:37.938Z","dependency_job_id":"51e72aed-51b4-497d-96c0-0fba649c9243","html_url":"https://github.com/zorgnax/libtap","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorgnax%2Flibtap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorgnax%2Flibtap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorgnax%2Flibtap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zorgnax%2Flibtap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zorgnax","download_url":"https://codeload.github.com/zorgnax/libtap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221553270,"owners_count":16841996,"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":[],"created_at":"2024-07-30T22:01:32.252Z","updated_at":"2025-12-28T16:07:26.413Z","avatar_url":"https://github.com/zorgnax.png","language":"C","funding_links":[],"categories":["TODO scan for Android support in followings","Debug","C","调试"],"sub_categories":[],"readme":"NAME\n====\n\nlibtap - Write tests in C\n\nSYNOPSIS\n========\n\n    #include \u003ctap.h\u003e\n\n    int main () {\n        plan(5);\n        int bronze = 1, silver = 2, gold = 3;\n        ok(bronze \u003c silver, \"bronze is less than silver\");\n        ok(bronze \u003e silver, \"not quite\");\n        is(\"gold\", \"gold\", \"gold is gold\");\n        cmp_ok(silver, \"\u003c\", gold, \"%d \u003c= %d\", silver, gold);\n        like(\"platinum\", \".*inum\", \"platinum matches .*inum\");\n        done_testing();\n    }\n\nresults in:\n\n    1..5\n    ok 1 - bronze is less than silver\n    not ok 2 - not quite\n    #   Failed test 'not quite'\n    #   at t/synopsis.c line 7.\n    ok 3 - gold is gold\n    ok 4 - 2 \u003c= 3\n    ok 5 - platinum matches .*inum\n    # Looks like you failed 1 test of 5 run.\n\nDESCRIPTION\n===========\n\ntap is an easy to read and easy to write way of creating tests for\nyour software. This library creates functions that can be used to\ngenerate it for your C programs. It is implemented using macros\nthat include file and line info automatically, and makes it so that\nthe format message of each test is optional. It is mostly based on\nthe Test::More Perl module.\n\nINSTALL\n=======\n\nOn **Unix** systems:\n\n    $ make\n    $ make install\n\nFor more detailed installation instructions (eg, for **Windows**), see `INSTALL`.\n\nFUNCTIONS\n=========\n\n-   plan(tests)\n-   plan(NO_PLAN)\n-   plan(SKIP_ALL);\n-   plan(SKIP_ALL, fmt, ...)\n\n    Use this to start a series of tests. When you know how many tests there\n    will be, you can put a number as a number of tests you expect to run. If\n    you do not know how many tests there will be, you can use plan(NO_PLAN)\n    or not call this function. When you pass it a number of tests to run, a\n    message similar to the following will appear in the output:\n\n        1..5\n\n    If you pass it SKIP_ALL, the whole test will be skipped.\n\n-   ok(test)\n-   ok(test, fmt, ...)\n\n    Specify a test. the test can be any statement returning a true or false\n    value. You may optionally pass a format string describing the test.\n\n        ok(r = reader_new(\"Of Mice and Men\"), \"create a new reader\");\n        ok(reader_go_to_page(r, 55), \"can turn the page\");\n        ok(r-\u003epage == 55, \"page turned to the right one\");\n\n    Should print out:\n\n        ok 1 - create a new reader\n        ok 2 - can turn the page\n        ok 3 - page turned to the right one\n\n    On failure, a diagnostic message will be printed out.\n\n        not ok 3 - page turned to the right one\n        #   Failed test 'page turned to the right one'\n        #   at reader.c line 13.\n\n-   is(got, expected)\n-   is(got, expected, fmt, ...)\n-   isnt(got, unexpected)\n-   isnt(got, unexpected, fmt, ...)\n\n    Tests that the string you got is what you expected. with isnt, it is the\n    reverse.\n\n        is(\"this\", \"that\", \"this is that\");\n\n    prints:\n\n        not ok 1 - this is that\n        #   Failed test 'this is that'\n        #   at is.c line 6.\n        #          got: 'this'\n        #     expected: 'that'\n\n-   cmp_ok(a, op, b)\n-   cmp_ok(a, op, b, fmt, ...)\n\n    Compares two ints with any binary operator that doesn't require an lvalue.\n    This is nice to use since it provides a better error message than an\n    equivalent ok.\n\n        cmp_ok(420, \"\u003e\", 666);\n\n    prints:\n\n        not ok 1\n        #   Failed test at cmpok.c line 5.\n        #     420\n        #         \u003e\n        #     666\n\n-   cmp_mem(got, expected, n)\n-   cmp_mem(got, expected, n, fmt, ...)\n\n    Tests that the first n bytes of the memory you got is what you expected.\n    NULL pointers for got and expected are handled (if either is NULL,\n    the test fails), but you need to ensure n is not too large.\n\n        char *a = \"foo\";\n        char *b = \"bar\";\n        cmp_mem(a, b, 3)\n\n    prints\n\n        not ok 1\n        #   Failed test at t/cmp_mem.c line 9.\n        #     Difference starts at offset 0\n        #          got: 0x66\n        #     expected: 0x62\n\n-   like(got, expected)\n-   like(got, expected, fmt, ...)\n-   unlike(got, unexpected)\n-   unlike(got, unexpected, fmt, ...)\n\n    Tests that the string you got matches the expected extended POSIX regex.\n    unlike is the reverse. These macros are the equivalent of a skip on\n    Windows.\n\n        like(\"stranger\", \"^s.(r).*\\\\1$\", \"matches the regex\");\n\n    prints:\n\n        ok 1 - matches the regex\n\n-   pass()\n-   pass(fmt, ...)\n-   fail()\n-   fail(fmt, ...)\n\n    Speciy that a test succeeded or failed. Use these when the statement is\n    longer than you can fit into the argument given to an ok() test.\n\n-   dies_ok(code)\n-   dies_ok(code, fmt, ...)\n-   lives_ok(code)\n-   lives_ok(code, fmt, ...)\n\n    Tests whether the given code causes your program to exit. The code gets\n    passed to a macro that will test it in a forked process. If the code\n    succeeds it will be executed in the parent process. You can test things\n    like passing a function a null pointer and make sure it doesnt\n    dereference it and crash.\n\n        dies_ok({abort();}, \"abort does close your program\");\n        dies_ok({int x = 0/0;}, \"divide by zero crash\");\n        lives_ok({pow(3.0, 5.0);}, \"nothing wrong with taking 3**5\");\n\n    On Windows, these macros are the equivalent of a skip.\n\n-   done_testing()\n\n    Summarizes the tests that occurred and exits the main function. If\n    there was no plan, it will print out the number of tests as.\n\n        1..5\n\n    It will also print a diagnostic message about how many\n    failures there were.\n\n        # Looks like you failed 2 tests of 3 run.\n\n    If all planned tests were successful, it will return 0. If any\n    test fails, it will return 1. If they all passed, but there\n    were missing tests, it will return 2.\n\n-   diag(fmt, ...)\n\n    print out a message to the tap output on stdout. Each line is\n    preceeded by a \"# \" so that you know its a diagnostic message.\n\n        diag(\"This is\\na diag\\nto describe\\nsomething.\");\n\n    prints:\n\n        # This is\n        # a diag\n        # to describe\n        # something\n\n    ok() and this function return an int so you can use it like:\n\n        ok(0) || diag(\"doh!\");\n\n-   skip(test, n)\n-   skip(test, n, fmt, ...)\n-   end_skip\n\n    Skip a series of n tests if test is true. You may give a reason why you are\n    skipping them or not. The (possibly) skipped tests must occur between the\n    skip and end_skip macros.\n\n        skip(TRUE, 2);\n        ok(1);\n        ok(0);\n        end_skip;\n\n    prints:\n\n        ok 1 # skip\n        ok 2 # skip\n\n-   todo()\n-   todo(fmt, ...)\n-   end_todo\n\n    Specifies a series of tests that you expect to fail because they are not\n    yet implemented.\n\n        todo()\n        ok(0);\n        end_todo;\n\n    prints:\n\n        not ok 1 # TODO\n        #   Failed (TODO) test at todo.c line 7\n\n-   BAIL_OUT()\n-   BAIL_OUT(fmt, ...)\n\n    Immediately stops all testing.\n\n        BAIL_OUT(\"Can't go no further\");\n\n    prints\n\n        Bail out!  Can't go no further\n\n    and exits with 255.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzorgnax%2Flibtap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzorgnax%2Flibtap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzorgnax%2Flibtap/lists"}