{"id":23674094,"url":"https://github.com/farism/assert","last_synced_at":"2026-01-27T03:01:29.601Z","repository":{"id":75170841,"uuid":"557745545","full_name":"farism/Assert","owner":"farism","description":"Assertion library for Beef","archived":false,"fork":false,"pushed_at":"2022-10-26T17:39:30.000Z","size":88,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-21T10:49:18.971Z","etag":null,"topics":["assert","assertion-library","beef","beef-language"],"latest_commit_sha":null,"homepage":"https://farism.github.io/Assert/html/","language":"Beef","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/farism.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-26T08:16:07.000Z","updated_at":"2022-12-10T19:32:56.000Z","dependencies_parsed_at":"2023-06-05T15:15:37.018Z","dependency_job_id":null,"html_url":"https://github.com/farism/Assert","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/farism/Assert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farism%2FAssert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farism%2FAssert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farism%2FAssert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farism%2FAssert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farism","download_url":"https://codeload.github.com/farism/Assert/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farism%2FAssert/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28798595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T01:07:07.743Z","status":"online","status_checked_at":"2026-01-27T02:00:07.755Z","response_time":168,"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":["assert","assertion-library","beef","beef-language"],"created_at":"2024-12-29T12:59:46.526Z","updated_at":"2026-01-27T03:01:29.589Z","avatar_url":"https://github.com/farism.png","language":"Beef","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\n`Assert` is an assertion library for the Beef programming language, loosely inspired by [Jest](https://jestjs.io/docs/getting-started)\n\nIt is an alternative to the Corlib `Test.Assert` function, which comes with some limitations.\n\nThe primary motivation for this library is that I wanted slightly better output than `Test.Assert` was providing. By passing in the values individually (rather than the boolen check that `Test.Assert` expects) we can then echo the values back to the user.\n\nIn addition to the values being tested, we can use the filepath and line info to read the problem file and show a code snippet of any failing assertions:\n\n```\nERROR: Test failed. \n \u003e\n \u003e Assert(val1 contains val2)\n \u003e\n \u003e val1: (1, 2, 3)\n \u003e val2: 4\n \u003e\n \u003e d:\\Projects\\Beef\\Assert\\src\\Assert.bf\n \u003e\n \u003e 284 | \n \u003e 285 | \t[Test]\n \u003e 286 | \tstatic void Assertions()\n \u003e 287 | \t{\n \u003e 288 | \t\tAssert.Eq(2 + 2, 4);\n \u003e 289 \u003e\u003e\u003e \t\tAssert.Contains(int[](1, 2, 3), 4);\n \u003e 290 | \t}\n \u003e 291 | \n```\n\n# Installing\n\n1. Clone this repo somewhere to your system.\n2. In the Beef IDE, right-click workspace panel select \"Add Existing Project\". Locate the directory you cloned earlier.\n3. For each project that will use `Assert`, right-click \u003e Properties \u003e Dependencies and select `Assert`.\n\n# Usage\n\n```bf\nusing Assert;\n\nAssert.Eq(1, 1);\n```\n\n# Features\n\nThere is basic support for numerics, Strings, and IEnumerables.\n\n## Numerics\n\n```bf\nAssert.Eq(1, 1);\n\nAssert.Neq(1, 2);\n\nAssert.Gt(2, 1);\n\nAssert.Gte(2, 1);\n\nAssert.Lt(1, 2);\n\nAssert.Lte(1, 2);\n\nAssert.CloseTo(1, 1.000001, 5);  // Close to within N digits (default: 2)\n```\n\n## String/StringView\n\nAssert can accept and compare both `String` and `StringView`.\n\n```bf\nAssert.Eq(String(\"hello world\"), StringView(\"hello world\")); // Interchangeable\n\nAssert.Neq(\"hello\", \"world\");\n\nAssert.Contains(\"hello world\", \" lo wo \");\n\nAssert.NotContains(\"hello world\", \"foobar\");\n\nAssert.StartsWith(\"hello world\", \"hello\");\n\nAssert.EndsWith(\"hello world\", \"world\");\n\nAssert.Length(\"hello world\", 11);\n```\n\n\n## IEnumerable\n\nAny `IEnumerable` (including `SizedArray`) can be used with `Assert`. \n\nFor `StartsWith`, `EndsWith`, `Contains` and `NotContains`, you can pass either another enumerable, or an individual element as the second parameter. All enumerable comparisons are contiguous.\n\n```bf\nAssert.Eq(int[](1, 2, 3), int[](1, 2, 3)); \n\nAssert.Neq(int[](1, 2, 3), int[](4, 5, 6)); \n\nAssert.Contains(int[](1, 2, 3), int[](1, 2)); \n\nAssert.Contains(int[](1, 2, 3), 1); \n\nAssert.NotContains(int[](1, 2, 3), int[](4, 5, 6)); \n\nAssert.NotContains(int[](1, 2, 3), 4); \n\nAssert.StartsWith(int[](1, 2, 3), int[](1, 2)); \n\nAssert.StartsWith(int[](1, 2, 3), 1); \n\nAssert.EndsWith(int[](1, 2, 3), int[](2, 3)); \n\nAssert.EndsWith(int[](1, 2, 3), 3); \n\nAssert.Length(int[](1, 2, 3, 4, 5), 5);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarism%2Fassert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarism%2Fassert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarism%2Fassert/lists"}