title: How can you test that an index is out of range in Swift?
body: <p>In a unit test, I want to assert that a method that has the potential to throw an index out of range error actually throws that error.</p>
  
  <p>I'm trying to use </p>
  
  <pre><code>let array = [1,2,3]
  XCTAssertThrowsError(array[3])    
  </code></pre>
  
  <p>Why doesn't this work?</p>
  
  <p>How do I test this?</p>