Skip to content

Commit

Permalink
Merge 9deb3d0 into 692ab8f
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-exini committed Oct 31, 2018
2 parents 692ab8f + 9deb3d0 commit ec11e12
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/scala/se/nimsa/dicom/data/CharacterSets.scala
Expand Up @@ -73,6 +73,13 @@ 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
}

override def hashCode(): Int = charsetNames.hashCode
}

object CharacterSets {
Expand Down
7 changes: 7 additions & 0 deletions src/test/scala/se/nimsa/dicom/data/CharacterSetsTest.scala
Expand Up @@ -103,6 +103,13 @@ 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
cs1.hashCode shouldBe cs2.hashCode
}

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 ec11e12

Please sign in to comment.