✅ [Solution] Swift: Complement of Base 10 Integer (+ test cases)
swift\nclass Solution {\n    func bitwiseComplement(_ n: Int) -> Int {\n        var s: Int = 1\n        while s < n { s = (s << 1) | 1 }\n        return s - n\n
```swift\nclass Solution {\n    func bitwiseComplement(_ n: Int) -> Int {\n        var s: Int = 1\n        while s < n { s = (s << 1) | 1 }\n        return s - n\n    }\n}\n```\n\n---\n\n<p>\n<details>\n<summary>\n<img src="https://git.io/JDblm" height="24">\n<b>TEST CASES</b>\n</summary>\n\n<p><pre>\n<b>Result:</b> Executed 3 tests, with 0 failures (0 unexpected) in 0.005 (0.006) seconds\n</pre></p>\n\n```swift\nimport XCTest\n\nclass Tests: XCTestCase {\n    \n    private let solution = Solution()\n    \n    /// 5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.\n    func test1() {\n        let value = solution.bitwiseComplement(5)\n        XCTAssertEqual(value, 2)\n    }\n    \n    /// 7 is "111" in binary, with complement "000" in binary, which is 0 in base-10.\n    func test2() {\n        let value = solution.bitwiseComplement(7)\n        XCTAssertEqual(value, 0)\n    }\n    \n    /// 10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.\n    func test3() {\n        let value = solution.bitwiseComplement(10)\n        XCTAssertEqual(value, 5)\n    }\n}\n\nTests.defaultTestSuite.run()\n```\n\n</details>\n</p>
['Swift']