Skip to content

Commit

Permalink
Equals method overridden. Test added
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-exini committed Oct 31, 2018
1 parent 692ab8f commit f56c0c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/scala/se/nimsa/dicom/data/CharacterSets.scala
Expand Up @@ -73,6 +73,11 @@ class CharacterSets(val charsetNames: Seq[String]) {
}

override def toString: String = s"${getClass.getSimpleName} [${specifiedCharsets.map(_.charset.toString).mkString(",")}]"

override def equals(that: Any): Boolean = that match {
case thatCharSets: CharacterSets => charsetNames == thatCharSets.charsetNames
case _ => this == that
}
}

object CharacterSets {
Expand Down
6 changes: 6 additions & 0 deletions src/test/scala/se/nimsa/dicom/data/CharacterSetsTest.scala
Expand Up @@ -103,6 +103,12 @@ class CharacterSetsTest extends TestKit(ActorSystem("CharacterSetsSpec")) with F
checkPatientName(name, nameCodePoints)
}

"CharacterSets" should "be comparable" in {
val cs1 = new CharacterSets(Seq("ISO 2022 IR 13", "ISO 2022 IR 87"))
val cs2 = new CharacterSets(Seq("ISO 2022 IR 13", "ISO 2022 IR 87"))
cs1 shouldBe cs2
}

private def checkPatientName(name: String, expectedCodePoints: Array[Int]): Unit = {
val codePoints = new Array[Int](name.codePointCount(0, name.length))
val length = name.length
Expand Down

0 comments on commit f56c0c2

Please sign in to comment.