Mercurial > hg > orthanc
changeset 2416:feb0d2dcfa9b
try and fix compiler bugs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Oct 2017 10:30:06 +0200 |
parents | 7e217a1cc63f |
children | a386c1140aab |
files | Core/DicomFormat/DicomImageInformation.cpp UnitTestsSources/DicomMapTests.cpp |
diffstat | 2 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomFormat/DicomImageInformation.cpp Mon Oct 02 22:02:05 2017 +0200 +++ b/Core/DicomFormat/DicomImageInformation.cpp Tue Oct 03 10:30:06 2017 +0200 @@ -178,18 +178,20 @@ throw OrthancException(ErrorCode_NotImplemented); } - try - { - numberOfFrames_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); - } - catch (OrthancException&) + if (values.HasTag(DICOM_TAG_NUMBER_OF_FRAMES)) { - // If the tag "NumberOfFrames" is absent, assume there is a single frame - numberOfFrames_ = 1; + try + { + numberOfFrames_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); + } + catch (boost::bad_lexical_cast&) + { + throw OrthancException(ErrorCode_NotImplemented); + } } - catch (boost::bad_lexical_cast&) + else { - throw OrthancException(ErrorCode_NotImplemented); + numberOfFrames_ = 1; } if ((bitsAllocated_ != 8 && bitsAllocated_ != 16 &&
--- a/UnitTestsSources/DicomMapTests.cpp Mon Oct 02 22:02:05 2017 +0200 +++ b/UnitTestsSources/DicomMapTests.cpp Tue Oct 03 10:30:06 2017 +0200 @@ -265,9 +265,9 @@ ASSERT_FLOAT_EQ(2147483647.0f, f); ASSERT_DOUBLE_EQ(2147483647.0, d); ASSERT_EQ(2147483647, i); - ASSERT_EQ(2147483647, j); + ASSERT_EQ(2147483647ll, j); ASSERT_EQ(2147483647u, k); - ASSERT_EQ(2147483647u, l); + ASSERT_EQ(2147483647llu, l); // Test shortcuts m.SetValue(DICOM_TAG_PATIENT_NAME, "42", false); @@ -280,9 +280,9 @@ ASSERT_FLOAT_EQ(42.0f, f); ASSERT_DOUBLE_EQ(42.0, d); ASSERT_EQ(42, i); - ASSERT_EQ(42, j); + ASSERT_EQ(42ll, j); ASSERT_EQ(42u, k); - ASSERT_EQ(42u, l); + ASSERT_EQ(42llu, l); ASSERT_TRUE(m.CopyToString(s, DICOM_TAG_PATIENT_NAME, false)); ASSERT_EQ("42", s); @@ -300,9 +300,9 @@ ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); ASSERT_FLOAT_EQ(2147483648.0f, f); ASSERT_DOUBLE_EQ(2147483648.0, d); - ASSERT_EQ(2147483648, j); + ASSERT_EQ(2147483648ll, j); ASSERT_EQ(2147483648u, k); - ASSERT_EQ(2147483648u, l); + ASSERT_EQ(2147483648llu, l); // 2**32-1 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967295", false); @@ -314,9 +314,9 @@ ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); ASSERT_FLOAT_EQ(4294967295.0f, f); ASSERT_DOUBLE_EQ(4294967295.0, d); - ASSERT_EQ(4294967295, j); + ASSERT_EQ(4294967295ll, j); ASSERT_EQ(4294967295u, k); - ASSERT_EQ(4294967295u, l); + ASSERT_EQ(4294967295llu, l); // 2**32 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967296", false); @@ -328,8 +328,8 @@ ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); ASSERT_FLOAT_EQ(4294967296.0f, f); ASSERT_DOUBLE_EQ(4294967296.0, d); - ASSERT_EQ(4294967296, j); - ASSERT_EQ(4294967296u, l); + ASSERT_EQ(4294967296ll, j); + ASSERT_EQ(4294967296llu, l); m.SetValue(DICOM_TAG_PATIENT_NAME, "-1", false); ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); @@ -341,7 +341,7 @@ ASSERT_FLOAT_EQ(-1.0f, f); ASSERT_DOUBLE_EQ(-1.0, d); ASSERT_EQ(-1, i); - ASSERT_EQ(-1, j); + ASSERT_EQ(-1ll, j); // -2**31 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483648", false); @@ -354,7 +354,7 @@ ASSERT_FLOAT_EQ(-2147483648.0f, f); ASSERT_DOUBLE_EQ(-2147483648.0, d); ASSERT_EQ(-2147483648, i); - ASSERT_EQ(-2147483648, j); + ASSERT_EQ(-2147483648ll, j); // -2**31 - 1 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483649", false); @@ -366,5 +366,5 @@ ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); ASSERT_FLOAT_EQ(-2147483649.0f, f); ASSERT_DOUBLE_EQ(-2147483649.0, d); - ASSERT_EQ(-2147483649, j); + ASSERT_EQ(-2147483649ll, j); }