{"id":18714165,"url":"https://github.com/pfultz2/prove","last_synced_at":"2025-10-25T10:41:40.218Z","repository":{"id":25418850,"uuid":"28848072","full_name":"pfultz2/Prove","owner":"pfultz2","description":"Lightweight C++ test framework","archived":false,"fork":false,"pushed_at":"2018-02-07T00:16:52.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-28T09:20:29.057Z","etag":null,"topics":["c-plus-plus","c-plus-plus-11","c-plus-plus-14","cpp","cpp11","cpp14","test-framework","unit-test","unit-tests","unittest"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfultz2.png","metadata":{"files":{"readme":"README.md","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":"2015-01-06T05:20:28.000Z","updated_at":"2019-05-11T11:25:55.000Z","dependencies_parsed_at":"2022-08-24T05:40:41.602Z","dependency_job_id":null,"html_url":"https://github.com/pfultz2/Prove","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/pfultz2%2FProve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FProve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FProve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2FProve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfultz2","download_url":"https://codeload.github.com/pfultz2/Prove/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576790,"owners_count":19662114,"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-plus-plus","c-plus-plus-11","c-plus-plus-14","cpp","cpp11","cpp14","test-framework","unit-test","unit-tests","unittest"],"created_at":"2024-11-07T12:51:36.611Z","updated_at":"2025-10-25T10:41:35.198Z","avatar_url":"https://github.com/pfultz2.png","language":"C++","readme":"Prove\n=====\n\nLightweight C++ test framework\n\nTest cases\n----------\n\nA test case can be created by using the `prove::test_case` class with a `test()` method:\n\n```cpp\nstruct my_case : prove::test_case\u003cmy_case\u003e\n{\n    void test()\n    {\n        // Assertions\n    }\n};\n```\n\nThe library will construct the object and then run the `test()` method. The constructor and destructor can be used for setup and teardown of each test. \n\nFor convience the `PROVE_CASE` macro can be used to define a class with a `test()` method to reduce the boilerplate:\n\n```cpp\nPROVE_CASE(my_case)\n{\n    // Assertions\n}\n```\n\nAlso, the `PROVE_CASE_CLASS` will define the class:\n\n```cpp\nPROVE_CASE_CLASS(my_case)\n{\n    void test()\n    {\n        // Assertions\n    }\n};\n```\n\nAlso, the name can be left out of the macros, and it will choose a unique name. \n\nFinally, to run all test cases, use `prove::run()`:\n\n```cpp\nint main() \n{\n    prove::run();\n}\n```\n\nAssertions\n----------\n\nThe `this-\u003echeck()` method can be used to check assertions:\n\n```cpp\nstruct my_case : prove::test_case\u003cmy_case\u003e\n{\n    void test()\n    {\n        this-\u003echeck(true);\n    }\n};\n```\n\nA custom message can be provided for the assertion as well:\n\n```cpp\nstruct my_case : prove::test_case\u003cmy_case\u003e\n{\n    void test()\n    {\n        this-\u003echeck(true, \"True is now false\");\n    }\n};\n```\n\nWhen checking expressions, it is useful to show the values that were used in the expression. The `PROVE_CHECK` macro can parse the expression and display the values that were used:\n\n```cpp\nPROVE_CASE()\n{\n    int i = 5;\n    PROVE_CHECK(i == 5);\n}\n```\n\nIt will also display the source file and line number in the output.\n\nCustom predicates\n-----------------\n\nThe `prove::predicate_result` can be used to display a custom message. For example,\n\n```cpp\nprove::predicate_result equal(int x, int y)\n{\n    prove::predicate_result r(x == y);\n    r \u003c\u003c x \u003c\u003c \" == \" \u003c\u003c y \u003c\u003c \" failed\";\n    return r;\n}\n\nstruct my_case : prove::test_case\u003cmy_case\u003e\n{\n    void test()\n    {\n        int i = 5;\n        this-\u003echeck(equal(i, 5));\n    }\n};\n```\n\nTemplate cases\n--------------\n\nCases can be templated or be defined as nested classes in a template class. For example, when defining a template case:\n\n```cpp\ntemplate\u003cclass T\u003e\nstruct template_case : prove::test_case\u003ctemplate_case\u003cT\u003e\u003e\n{\n    void test()\n    {\n        T i = 5;\n        PROVE_CHECK(i == 5);\n    }\n};\n```\n\nEach template parameter can be used by the following:\n\n```cpp\ntemplate struct template_case\u003cint\u003e;\ntemplate struct template_case\u003cfloat\u003e;\n```\n\nIf there is many test case that are parameterized over the same template parameter, then each test case can be added as a nested class:\n\n```cpp\ntemplate\u003cclass T\u003e\nstruct template_suite\n{\n    struct template_case1 : prove::test_case\u003ctemplate_case1\u003cT\u003e\u003e\n    {\n        void test()\n        {\n            T i = 5;\n            PROVE_CHECK(i == 5);\n        }\n    };\n\n    struct template_case2 : prove::test_case\u003ctemplate_case2\u003cT\u003e\u003e\n    {\n        void test()\n        {\n            T i = 3;\n            PROVE_CHECK(i == 3);\n        }\n    };\n};\n\ntemplate struct template_suite\u003cint\u003e;\ntemplate struct template_suite\u003cfloat\u003e;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fprove","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfultz2%2Fprove","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fprove/lists"}