From f93fa664fddd1dc7c041af4a756a1abf00952520 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Fri, 22 Mar 2024 22:48:27 +0100 Subject: [PATCH] ErrorMessagesSpec: make failures easier to read Old output of `sbt test`: ``` ErrorMessagesSpec: - attr_invalid_switch_inner *** FAILED *** attr_invalid_switch_inner.ksy: /seq/1/size: error: invalid type: expected integer, got CalcBooleanType attr_invalid_switch_inner.ksy: /seq/1/size: error: invalid type: expected integer, got CalcBooleanType did not equal attr_invalid_switch_inner.ksy: /seq/1/size: error: invalid type: expected integer, got CalcBooleanType (SimpleMatchers.scala:34) ``` New output of `sbt test`: ``` ErrorMessagesSpec: - attr_invalid_switch_inner *** FAILED *** [attr_invalid_switch_inner.ksy: /seq/1/size: error: invalid type: expected integer, got CalcBooleanType attr_invalid_switch_inner.ksy: /seq/1/size: error: invalid type: expected integer, got CalcBooleanType ] did not equal [attr_invalid_switch_inner.ksy: /seq/1/size: error: invalid type: expected integer, got CalcBooleanType ] (SimpleMatchers.scala:34) ``` --- jvm/src/test/scala/io/kaitai/struct/SimpleMatchers.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm/src/test/scala/io/kaitai/struct/SimpleMatchers.scala b/jvm/src/test/scala/io/kaitai/struct/SimpleMatchers.scala index 53eeed45d..8ecfb5496 100644 --- a/jvm/src/test/scala/io/kaitai/struct/SimpleMatchers.scala +++ b/jvm/src/test/scala/io/kaitai/struct/SimpleMatchers.scala @@ -29,7 +29,7 @@ trait SimpleMatchers { def shouldEqualPlainly(right: Any)(implicit equality: Equality[T]): Assertion = if (!equality.areEqual(leftSideValue, right)) { throw new exceptions.TestFailedException( - (e: exceptions.StackDepthException) => Some(s"""${leftSideValue} did not equal ${right}"""), + (e: exceptions.StackDepthException) => Some(s"""[${leftSideValue}]\n did not equal\n[${right}]"""), None, Position.here )