{"id":22954148,"url":"https://github.com/atomicptr/rapture","last_synced_at":"2025-04-02T00:22:05.196Z","repository":{"id":266550197,"uuid":"850239944","full_name":"atomicptr/rapture","owner":"atomicptr","description":"A tiny, single file, header only assertion library for C++23","archived":false,"fork":false,"pushed_at":"2025-02-16T13:16:48.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T02:49:57.215Z","etag":null,"topics":["assert","assertion-library","cpp","cpp23","header-only","header-only-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomicptr.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":"2024-08-31T08:31:12.000Z","updated_at":"2025-02-16T13:16:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"8964ad46-896a-46c5-ab48-ceba14a738b7","html_url":"https://github.com/atomicptr/rapture","commit_stats":null,"previous_names":["atomicptr/rapture"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Frapture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Frapture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Frapture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Frapture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicptr","download_url":"https://codeload.github.com/atomicptr/rapture/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246731142,"owners_count":20824511,"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":["assert","assertion-library","cpp","cpp23","header-only","header-only-library"],"created_at":"2024-12-14T16:16:11.729Z","updated_at":"2025-04-02T00:22:05.187Z","avatar_url":"https://github.com/atomicptr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rapture\n\nA tiny single file header only assertion library for C++23\n\nThis library makes use of std::print, std::format and std::source_location so make sure your compiler supports this!\n\n## Provides\n\n- assert(condition, message) - If the condition fails, crashes the program with message\n- expect(condition) - Assert but without message\n- panic(message) - Crashes the program with message\n- unreachable() - Crashes the program with message, used to make sure unreachable code sections will not be run\n- unimplemented() - Crashes the program with message, used to mark certain code paths as unimplemented\n\nSee How to use section or examples\n\n## Install\n\nJust copy the file into your project and adjust accordingly\n\n## How to use\n\n\u003cdetails\u003e\n\u003csummary\u003eExample: assert\u003c/summary\u003e\n\n```cpp\nint main() {\n    auto a = 5;\n    auto b = 7;\n\n    // this assertion is correct -\u003e will continue\n    assert(a + b == 12, \"{} + {} should be {}\", a, b, 12);\n\n    // this assertion is wrong -\u003e hence the program will crash\n    auto c = 2;\n    assert(c + c == 5, \"{} + {} should be {}\", c, c, 5);\n\n    return 0;\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eExample: expect\u003c/summary\u003e\n\n```cpp\nint main() {\n    auto a = 5;\n    auto b = 7;\n\n    // this expection is correct -\u003e will continue\n    expect(a + b == 12);\n\n    // this expection is wrong -\u003e hence the program will crash\n    auto c = 2;\n    expect(c + c == 5);\n\n    return 0;\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eExample: panic\u003c/summary\u003e\n\n```cpp\nint safeDiv(int a, int b) {\n    if (b == 0) {\n        panic(\"can't divide by zero\");\n    }\n\n    return a / b;\n}\n\nint main() {\n    std::println(\"{} / {} = {}\", 10, 2, safeDiv(10, 2));\n    std::println(\"{} / {} = {}\", 10, 0, safeDiv(10, 0));\n}\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eExample: unreachable\u003c/summary\u003e\n\n```cpp\nenum class State {\n    A,\n    B,\n    C // newly added\n};\n\nvoid print_state(State s) {\n    switch (s) {\n    case State::A:\n        std::println(\"State::A\");\n        return;\n    case State::B:\n        std::println(\"State::B\");\n        return;\n    default: // never added here though...\n        unreachable();\n    }\n}\n\nint main() {\n    print_state(State::A);\n    print_state(State::B);\n    print_state(State::C);\n}\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eExample: unimplemented\u003c/summary\u003e\n\n```cpp\nvoid solve_every_problem_in_the_universe() {\n    unimplemented();\n}\n\nint main(void) {\n    solve_every_problem_in_the_universe();\n}\n````\n\n\u003c/details\u003e\n\n## License\n\nBSD 0-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Frapture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicptr%2Frapture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Frapture/lists"}