title: How to assert the value of an optional Bool in Swift unit test?
body: <p>I have a Swift unit test similar to the following:</p>
  
  <pre><code>var firstArgumentInClosure: Bool?
  someFunc { firstArgumentInClosure = $0 }
  XCTAssertTrue(firstArgumentInClosure?)
  </code></pre>
  
  <p>I'm trying to assert the closure was called with the first argument being <code>true</code>.</p>
  
  <p>This doesn't compile with error message:</p>
  
  <blockquote>
    <p>'?' must be followed by a call, member lookup, or subscript</p>
  </blockquote>
  
  <p>One way I can fix this is by changing the assertion to:</p>
  
  <pre><code>XCTAssertEqualTrue(firstArgumentInClosure ?? false)
  </code></pre>
  
  <p>Is there no more concise way to do this? It's a bit strange to see the <code>??
   false</code>. I also don't want to implicitly unwrap the optional with <code>!</code> because I don't want that to crash the test, I just want the test to fail if <code>firstArgumentInClosure</code> is <code>nil</code> or <code>false</code>. I also want to avoid any <code>if let</code>s to keep things concise. </p>
  
  <p>Similarly, how would I write such an assertion when I'm trying to use <code>XCTAssertFalse</code> to ensure a <code>Bool?</code> is <code>false</code>?</p>