title: ScalaTest deep comparison best practices
body: <p>I'm trying to write a unit test for a function that returns a tuple of a class that contains an array.</p>
  
  <p>A simple <code>assert(out === expectedOut)</code> or <code>out should be(expectedOut)</code> does not compare the contents of the classes on the LHS and RHS because of the Array. Is there a neat way to do that in ScalaTest?</p>
  
  <p>I've looked at custom matchers but I'm not sure if that's the best way for what I'm trying to do. So any info from experience of the experts would be much appreciated.</p>
  
  <p>Edit:
  Here is a case where that does not seem to be the case:</p>
  
  <pre><code>object Utils {
    case class Product(id: Int, prices: Array[Int])
  
  
    def getProductInfo(id: Int, prices: Array[Int]): Option[Product] = {
      val sortedPrices = prices.sortWith(_ &lt; _)
      Some(Product(id, sortedPrices))
    }
  }
  
  ---
  
  import org.scalatest._
  import Utils._
  
  class DataProcessorSpec extends FlatSpec with Matchers with OptionValues {
    val id = 12345
    val priceList = Array(10,20,30)
  
    val prod = Utils.getProductInfo(id, priceList)
    val expectedProd = Some(Utils.Product(id, priceList))
  
    "A DataProcessorSpec" should "return the correct product information" in {
       prod should be(expectedProd)
    }
  }
  </code></pre>
  
  <p>The test fails because the <code>sortWith</code> causes a new array to be created and is thus pointing to a different memory location, as far as I can tell.</p>