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
4 changes: 2 additions & 2 deletions Modules/IO/MeshBase/include/itkMeshFileReader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Co
<< "to one of: " << std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<unsigned char>::CType)
<< std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<char>::CType) << std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<signed char>::CType) << std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<unsigned short>::CType)
<< std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<short>::CType) << std::endl
Expand Down Expand Up @@ -799,7 +799,7 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Co
<< "to one of: " << std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<unsigned char>::CType)
<< std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<char>::CType) << std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<signed char>::CType) << std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<unsigned short>::CType)
<< std::endl
<< " " << MeshIOBase::GetComponentTypeAsString(MeshIOBase::MapComponentType<short>::CType) << std::endl
Expand Down
5 changes: 3 additions & 2 deletions Modules/IO/MeshBase/include/itkMeshIOBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ class ITKIOMeshBase_EXPORT MeshIOBase : public LightProcessObject
struct MapComponentType
{
static constexpr IOComponentEnum CType =
std::is_same_v<TComponent, unsigned char> ? IOComponentEnum::UCHAR
: std::is_same_v<TComponent, char> ? IOComponentEnum::CHAR
std::is_same_v<TComponent, char> ? (std::is_signed_v<char> ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR)
: std::is_same_v<TComponent, signed char> ? IOComponentEnum::CHAR
: std::is_same_v<TComponent, unsigned char> ? IOComponentEnum::UCHAR
: std::is_same_v<TComponent, short> ? IOComponentEnum::SHORT
: std::is_same_v<TComponent, unsigned short> ? IOComponentEnum::USHORT
: std::is_same_v<TComponent, int> ? IOComponentEnum::INT
Expand Down
6 changes: 5 additions & 1 deletion Modules/IO/MeshBase/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ itk_add_test(
${ITK_TEST_OUTPUT_DIR}/itkMeshFileReaderWriterTest.vtk
)

set(ITKIOMeshBaseGTests itkMeshIOExceptionsGTest.cxx)
set(
ITKIOMeshBaseGTests
itkMeshIOBaseGTest.cxx
itkMeshIOExceptionsGTest.cxx
)
creategoogletestdriver(ITKIOMeshBase "${ITKIOMeshBase-Test_LIBRARIES}" "${ITKIOMeshBaseGTests}")
48 changes: 48 additions & 0 deletions Modules/IO/MeshBase/test/itkMeshIOBaseGTest.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/


#include "itkMeshIOBase.h"
#include <type_traits>

namespace
{
// Tests `MeshIOBase::MapComponentType<TComponent>::CType`.
using itk::IOComponentEnum;
using itk::MeshIOBase;

struct UnknownComponentType
{};
static_assert(MeshIOBase::MapComponentType<UnknownComponentType>::CType == IOComponentEnum::UNKNOWNCOMPONENTTYPE);

static_assert(MeshIOBase::MapComponentType<unsigned char>::CType == IOComponentEnum::UCHAR);
static_assert(MeshIOBase::MapComponentType<signed char>::CType == IOComponentEnum::CHAR);
static_assert(MeshIOBase::MapComponentType<char>::CType ==
(std::is_signed_v<char> ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR));
static_assert(MeshIOBase::MapComponentType<unsigned short>::CType == IOComponentEnum::USHORT);
static_assert(MeshIOBase::MapComponentType<short>::CType == IOComponentEnum::SHORT);
static_assert(MeshIOBase::MapComponentType<unsigned int>::CType == IOComponentEnum::UINT);
static_assert(MeshIOBase::MapComponentType<int>::CType == IOComponentEnum::INT);
static_assert(MeshIOBase::MapComponentType<unsigned long>::CType == IOComponentEnum::ULONG);
static_assert(MeshIOBase::MapComponentType<long>::CType == IOComponentEnum::LONG);
static_assert(MeshIOBase::MapComponentType<unsigned long long>::CType == IOComponentEnum::ULONGLONG);
static_assert(MeshIOBase::MapComponentType<long long>::CType == IOComponentEnum::LONGLONG);
static_assert(MeshIOBase::MapComponentType<float>::CType == IOComponentEnum::FLOAT);
static_assert(MeshIOBase::MapComponentType<double>::CType == IOComponentEnum::DOUBLE);
static_assert(MeshIOBase::MapComponentType<long double>::CType == IOComponentEnum::LDOUBLE);
} // namespace
Loading