From 5fc170069a0996fdf0bd1991b32b35c9a7d2fffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Sj=C3=B6strand?= Date: Mon, 15 May 2017 07:23:20 -0400 Subject: [PATCH] Fixed use of bytes vs valueBytes in DicomAttributesSink --- .../se/nimsa/dcm4che/streams/DicomAttributesSink.scala | 4 ++-- .../scala/se/nimsa/dcm4che/streams/DicomPartsTest.scala | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/scala/se/nimsa/dcm4che/streams/DicomAttributesSink.scala b/src/main/scala/se/nimsa/dcm4che/streams/DicomAttributesSink.scala index 9e1432d..2b6b89e 100644 --- a/src/main/scala/se/nimsa/dcm4che/streams/DicomAttributesSink.scala +++ b/src/main/scala/se/nimsa/dcm4che/streams/DicomAttributesSink.scala @@ -36,7 +36,7 @@ object DicomAttributesSink { if (header.length == 0) fmi.setNull(header.tag, header.vr) else { - val bytes = dicomAttribute.bytes.toArray + val bytes = dicomAttribute.valueBytes.toArray if (!DicomParsing.isGroupLength(header.tag)) { if (dicomAttribute.bigEndian != fmi.bigEndian) header.vr.toggleEndian(bytes, false) fmi.setBytes(header.tag, header.vr, bytes) @@ -52,7 +52,7 @@ object DicomAttributesSink { attributesData } else { - val bytes = dicomAttribute.bytes.toArray + val bytes = dicomAttribute.valueBytes.toArray if (!DicomParsing.isGroupLength(header.tag)) { if (attributesData.attributesStack.nonEmpty && dicomAttribute.bigEndian != attributesData.attributesStack.head.bigEndian) header.vr.toggleEndian(bytes, false) diff --git a/src/test/scala/se/nimsa/dcm4che/streams/DicomPartsTest.scala b/src/test/scala/se/nimsa/dcm4che/streams/DicomPartsTest.scala index d19cd43..c26089d 100644 --- a/src/test/scala/se/nimsa/dcm4che/streams/DicomPartsTest.scala +++ b/src/test/scala/se/nimsa/dcm4che/streams/DicomPartsTest.scala @@ -47,8 +47,9 @@ class DicomPartsTest extends FlatSpecLike with Matchers { val value = DicomValueChunk(false, patientNameJohnDoe.drop(8) ,true) val attribute = DicomAttribute(header, Seq(value)) val updatedAttribute = attribute.withUpdatedStringValue("Jimmyboy^Doe") - updatedAttribute.bytes.size shouldEqual 12 + updatedAttribute.valueBytes.size shouldEqual 12 updatedAttribute.header.length shouldEqual 12 + updatedAttribute.bytes.size shouldEqual 20 } it should "should return a new attribute with updated header and updated value with padding" in { @@ -58,8 +59,8 @@ class DicomPartsTest extends FlatSpecLike with Matchers { val attribute = DicomAttribute(header, Seq(value)) val updatedAttribute = attribute.withUpdatedStringValue("Jimmy^Doe") - updatedAttribute.bytes.size shouldEqual 10 + updatedAttribute.valueBytes.size shouldEqual 10 updatedAttribute.header.length shouldEqual 10 - updatedAttribute.bytes.drop(9) shouldEqual ByteString(32) + updatedAttribute.valueBytes.drop(9) shouldEqual ByteString(32) } }