Mercurial > hg > orthanc
changeset 5650:c2817a9eb032
unit test
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Wed, 05 Jun 2024 11:03:45 +0200 |
parents | 4a2bfda999c6 |
children | c4e33e0f907b |
files | OrthancServer/UnitTestsSources/UnitTestsMain.cpp |
diffstat | 1 files changed, 40 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/UnitTestsSources/UnitTestsMain.cpp Mon Jun 03 14:30:30 2024 +0200 +++ b/OrthancServer/UnitTestsSources/UnitTestsMain.cpp Wed Jun 05 11:03:45 2024 +0200 @@ -242,42 +242,53 @@ Json::Value dicomAsJson; OrthancConfiguration::DefaultDicomDatasetToJson(dicomAsJson, toStore->GetParsedDicomFile()); - DicomMap m; - m.FromDicomAsJson(dicomAsJson); + { // without parsing sequences + DicomMap m; + m.FromDicomAsJson(dicomAsJson); - ASSERT_EQ("ISO_IR 100", m.GetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET).GetContent()); - - ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).IsBinary()); - ASSERT_EQ("Hello", m.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); - - ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).IsBinary()); - ASSERT_EQ(utf8, m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); + ASSERT_EQ("ISO_IR 100", m.GetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET).GetContent()); + + ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).IsBinary()); + ASSERT_EQ("Hello", m.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); + + ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).IsBinary()); + ASSERT_EQ(utf8, m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); - ASSERT_FALSE(m.HasTag(DICOM_TAG_MANUFACTURER)); // Too long - ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); // Pixel data - ASSERT_FALSE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); // Sequence - ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetGroup(), DCM_ReferencedSeriesSequence.getGroup()); - ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetElement(), DCM_ReferencedSeriesSequence.getElement()); + ASSERT_FALSE(m.HasTag(DICOM_TAG_MANUFACTURER)); // Too long + ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); // Pixel data + ASSERT_FALSE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); // Sequence + ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetGroup(), DCM_ReferencedSeriesSequence.getGroup()); + ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetElement(), DCM_ReferencedSeriesSequence.getElement()); + + ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_DESCRIPTION)); // Maximum length + ASSERT_FALSE(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).IsBinary()); + ASSERT_EQ(ORTHANC_MAXIMUM_TAG_LENGTH, + static_cast<int>(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent().length())); - ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_DESCRIPTION)); // Maximum length - ASSERT_FALSE(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).IsBinary()); - ASSERT_EQ(ORTHANC_MAXIMUM_TAG_LENGTH, - static_cast<int>(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent().length())); + ASSERT_FALSE(m.GetValue(DICOM_TAG_ROWS).IsBinary()); + ASSERT_EQ("512", m.GetValue(DICOM_TAG_ROWS).GetContent()); - ASSERT_FALSE(m.GetValue(DICOM_TAG_ROWS).IsBinary()); - ASSERT_EQ("512", m.GetValue(DICOM_TAG_ROWS).GetContent()); + ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsNull()); + ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsBinary()); + ASSERT_EQ("", m.GetValue(DICOM_TAG_STUDY_ID).GetContent()); + + DicomArray a(m); + ASSERT_EQ(6u, a.GetSize()); - ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsNull()); - ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsBinary()); - ASSERT_EQ("", m.GetValue(DICOM_TAG_STUDY_ID).GetContent()); + + //dicom.SaveToFile("/tmp/test.dcm"); + //std::cout << toStore.GetJson() << std::endl; + //a.Print(stdout); + } - DicomArray a(m); - ASSERT_EQ(6u, a.GetSize()); + { // now parses sequences + // LOG(INFO) << dicomAsJson.toStyledString(); - - //dicom.SaveToFile("/tmp/test.dcm"); - //std::cout << toStore.GetJson() << std::endl; - //a.Print(stdout); + DicomMap m; + m.FromDicomAsJson(dicomAsJson, false, true /* parseSequences */); + + ASSERT_TRUE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); + } }