How do I get meaningful error messages for nested scala unit equality matchers? -


i want assert equality in scalatest of case classes contain array. (so built-in equality matchers case classes not applicable.) example:

case class example(array: array[double], variable: integer) 

test stub:

val = example(array(0.1, 0.2), 1) val b = example(array(0.1, 0.2), 1) should equal (b) 

fails expected. implement equality trait:

implicit val exampleeq = new equality[example] {   def areequal(left: example, right: any): boolean =     right match {       case other: example => {         left.array should contain thesameelementsinorderas other.array         left.variable should other.variable         true       }       case _ => false     } } 

which works. other option implement equality trait == @ places of "should be" , in case false @ 1 place return false, else true. problem both when running test error message both "example" objects not equal (if not) see in element differ.

how achieve this?

thank help!

[update] in practice example contains multiple arrays , other fields, changed code accordingly.

considered using:

left.array should contain thesameelementsinorderas other.array 

reference: working "sequences".


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -