diff --git a/Modules/Core/Common/include/itkCommonEnums.h b/Modules/Core/Common/include/itkCommonEnums.h index 44e51474159..d6d2422f059 100644 --- a/Modules/Core/Common/include/itkCommonEnums.h +++ b/Modules/Core/Common/include/itkCommonEnums.h @@ -22,6 +22,7 @@ #include "itkIntTypes.h" #include +#include namespace itk { @@ -86,7 +87,17 @@ class CommonEnums ULONGLONG, FLOAT, DOUBLE, - LDOUBLE + LDOUBLE, + UINT8 = UCHAR, + INT8 = CHAR, + UINT16 = USHORT, + INT16 = SHORT, + UINT32 = std::is_same_v ? ULONG : UINT, + INT32 = std::is_same_v ? LONG : INT, + UINT64 = std::is_same_v ? ULONG : ULONGLONG, + INT64 = std::is_same_v ? LONG : LONGLONG, + FLOAT32 = FLOAT, + FLOAT64 = DOUBLE }; /** diff --git a/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx b/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx index 25b8efca17c..64cb2c64230 100644 --- a/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx @@ -19,10 +19,50 @@ #include "itkMetaImageIO.h" #include "itkTestingMacros.h" #include "itkImage.h" +#include "itkIntTypes.h" #include "itkVectorImage.h" #include "itkImageIOFactory.h" // required to instantiate an instance of ImageIOBase +namespace +{ +// Tests `MapPixelType::CType` +class TestMapPixelType : private itk::ImageIOBase +{ + struct UnknownComponentType + {}; + static_assert(MapPixelType::CType == IOComponentEnum::UNKNOWNCOMPONENTTYPE); + + // Test built-in types: + static_assert(MapPixelType::CType == IOComponentEnum::UCHAR); + static_assert(MapPixelType::CType == IOComponentEnum::CHAR); + static_assert(MapPixelType::CType == (std::is_signed_v ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR)); + static_assert(MapPixelType::CType == IOComponentEnum::USHORT); + static_assert(MapPixelType::CType == IOComponentEnum::SHORT); + static_assert(MapPixelType::CType == IOComponentEnum::UINT); + static_assert(MapPixelType::CType == IOComponentEnum::INT); + static_assert(MapPixelType::CType == IOComponentEnum::ULONG); + static_assert(MapPixelType::CType == IOComponentEnum::LONG); + static_assert(MapPixelType::CType == IOComponentEnum::ULONGLONG); + static_assert(MapPixelType::CType == IOComponentEnum::LONGLONG); + static_assert(MapPixelType::CType == IOComponentEnum::FLOAT); + static_assert(MapPixelType::CType == IOComponentEnum::DOUBLE); + + // Test fixed width types: + static_assert(MapPixelType::CType == IOComponentEnum::UINT8); + static_assert(MapPixelType::CType == IOComponentEnum::INT8); + static_assert(MapPixelType::CType == IOComponentEnum::UINT16); + static_assert(MapPixelType::CType == IOComponentEnum::INT16); + static_assert(MapPixelType::CType == IOComponentEnum::UINT32); + static_assert(MapPixelType::CType == IOComponentEnum::INT32); + static_assert(MapPixelType::CType == IOComponentEnum::UINT64); + static_assert(MapPixelType::CType == IOComponentEnum::INT64); + static_assert(MapPixelType::CType == IOComponentEnum::FLOAT32); + static_assert(MapPixelType::CType == IOComponentEnum::FLOAT64); +}; +} // namespace + + // Specific ImageIO test int