{"id":25146909,"url":"https://github.com/dtroupe18/xctassertfunctionbuilder","last_synced_at":"2025-04-03T06:46:29.354Z","repository":{"id":123633372,"uuid":"270375345","full_name":"dtroupe18/XCTAssertFunctionBuilder","owner":"dtroupe18","description":"Write XCTAssertTrue \u0026\u0026 XCTAssertFalse less","archived":false,"fork":false,"pushed_at":"2020-06-07T17:13:49.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T20:32:42.916Z","etag":null,"topics":["dotsw","function-bu","functionb","playgr","swift5","unit-testing","xctas","xctest"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/dtroupe18.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":"2020-06-07T17:09:13.000Z","updated_at":"2020-06-07T17:13:51.000Z","dependencies_parsed_at":"2023-06-13T04:15:51.819Z","dependency_job_id":null,"html_url":"https://github.com/dtroupe18/XCTAssertFunctionBuilder","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/dtroupe18%2FXCTAssertFunctionBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtroupe18%2FXCTAssertFunctionBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtroupe18%2FXCTAssertFunctionBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtroupe18%2FXCTAssertFunctionBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtroupe18","download_url":"https://codeload.github.com/dtroupe18/XCTAssertFunctionBuilder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246952273,"owners_count":20859811,"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":["dotsw","function-bu","functionb","playgr","swift5","unit-testing","xctas","xctest"],"created_at":"2025-02-08T20:28:00.818Z","updated_at":"2025-04-03T06:46:29.338Z","avatar_url":"https://github.com/dtroupe18.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XCTAssertFunctionBuilder\nWrite XCTAssertTrue \u0026amp;\u0026amp; XCTAssertFalse less\n\nPulled this function builder from this great talk at [DotSwift](https://www.youtube.com/watch?utm_campaign=iOS%2BDev%2BWeekly\u0026utm_medium=email\u0026utm_source=iOS%2BDev%2BWeekly%2BIssue%2B459\u0026v=Or6xjaCUCd4).\n\n\n## User function builder to pass multiple statements to `XCTAssertTrue` or `XCTAssertFalse`.\n\n```swift\n  import Foundation\n  import XCTest\n\n  @_functionBuilder\n  class BooleanFunctionBuilder {\n    static func buildBlock(_ children: Bool...) -\u003e [Bool] {\n      return children\n    }\n  }\n\n  public func assertTrue(@BooleanFunctionBuilder builder: () -\u003e [Bool]) {\n    let expressions = builder()\n    expressions.forEach { XCTAssertTrue($0) }\n  }\n\n  public func assertFalse(@BooleanFunctionBuilder builder: () -\u003e [Bool]) {\n    let expressions = builder()\n    expressions.forEach { XCTAssertFalse($0) }\n  }\n```\n\n## Example Usage.\n\n```swift\n\n  public class TestClass: XCTestCase {\n    let a = 3\n    let b = 4\n    let c = 5\n\n    func testValues() {\n      assertTrue {\n        a * a + b * b == c * c\n        a == 3\n        b == 4\n        c == 5\n      }\n\n      assertFalse {\n        a + b == c\n        a + b \u003c c\n      }\n    }\n  }\n\n  // Run in a playground.\n  \n  TestClass.defaultTestSuite.run()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtroupe18%2Fxctassertfunctionbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtroupe18%2Fxctassertfunctionbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtroupe18%2Fxctassertfunctionbuilder/lists"}