Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Modules/Core/Common/include/itkCommonEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "itkIntTypes.h"
#include <ostream>
#include <type_traits>

namespace itk
{
Expand Down Expand Up @@ -86,7 +87,17 @@ class CommonEnums
ULONGLONG,
FLOAT,
DOUBLE,
LDOUBLE
LDOUBLE,
UINT8 = UCHAR,
INT8 = CHAR,
UINT16 = USHORT,
INT16 = SHORT,
UINT32 = std::is_same_v<uint32_t, unsigned long> ? ULONG : UINT,
INT32 = std::is_same_v<int32_t, long> ? LONG : INT,
UINT64 = std::is_same_v<uint64_t, unsigned long> ? ULONG : ULONGLONG,
INT64 = std::is_same_v<int64_t, long> ? LONG : LONGLONG,
FLOAT32 = FLOAT,
FLOAT64 = DOUBLE
};

/**
Expand Down
40 changes: 40 additions & 0 deletions Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<TPixel>::CType`
class TestMapPixelType : private itk::ImageIOBase
{
struct UnknownComponentType
{};
static_assert(MapPixelType<UnknownComponentType>::CType == IOComponentEnum::UNKNOWNCOMPONENTTYPE);

// Test built-in types:
static_assert(MapPixelType<unsigned char>::CType == IOComponentEnum::UCHAR);
static_assert(MapPixelType<signed char>::CType == IOComponentEnum::CHAR);
static_assert(MapPixelType<char>::CType == (std::is_signed_v<char> ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR));
static_assert(MapPixelType<unsigned short>::CType == IOComponentEnum::USHORT);
static_assert(MapPixelType<short>::CType == IOComponentEnum::SHORT);
static_assert(MapPixelType<unsigned int>::CType == IOComponentEnum::UINT);
static_assert(MapPixelType<int>::CType == IOComponentEnum::INT);
static_assert(MapPixelType<unsigned long>::CType == IOComponentEnum::ULONG);
static_assert(MapPixelType<long>::CType == IOComponentEnum::LONG);
static_assert(MapPixelType<unsigned long long>::CType == IOComponentEnum::ULONGLONG);
static_assert(MapPixelType<long long>::CType == IOComponentEnum::LONGLONG);
static_assert(MapPixelType<float>::CType == IOComponentEnum::FLOAT);
static_assert(MapPixelType<double>::CType == IOComponentEnum::DOUBLE);

// Test fixed width types:
static_assert(MapPixelType<uint8_t>::CType == IOComponentEnum::UINT8);
static_assert(MapPixelType<int8_t>::CType == IOComponentEnum::INT8);
static_assert(MapPixelType<uint16_t>::CType == IOComponentEnum::UINT16);
static_assert(MapPixelType<int16_t>::CType == IOComponentEnum::INT16);
static_assert(MapPixelType<uint32_t>::CType == IOComponentEnum::UINT32);
static_assert(MapPixelType<int32_t>::CType == IOComponentEnum::INT32);
static_assert(MapPixelType<uint64_t>::CType == IOComponentEnum::UINT64);
static_assert(MapPixelType<int64_t>::CType == IOComponentEnum::INT64);
static_assert(MapPixelType<float>::CType == IOComponentEnum::FLOAT32);
static_assert(MapPixelType<double>::CType == IOComponentEnum::FLOAT64);
};
} // namespace


// Specific ImageIO test

int
Expand Down
Loading