18#ifndef elxGTestUtilities_h
19#define elxGTestUtilities_h
21#include <itkOptimizerParameters.h>
24#include <itkSmartPointer.h>
28#include <gtest/gtest.h>
37namespace GTestUtilities
41template <
typename TMap>
45 const auto endOfMap2 = map2.end();
47 for (
const auto & keyValuePair : map1)
49 EXPECT_EQ(map2.find(keyValuePair.first), endOfMap2);
55template <
typename TMap>
60 for (
const auto & keyValuePair : map2)
62 map1.insert(keyValuePair);
70template <
typename TElastix>
71itk::SmartPointer<TElastix>
74 using FixedImageType =
typename TElastix::FixedImageType;
75 using MovingImageType =
typename TElastix::MovingImageType;
77 const auto elastixObject = TElastix::New();
79 elastixObject->SetConfiguration(elx::Configuration::New());
81 const auto fixedImageContainer = elx::ElastixBase::DataObjectContainerType::New();
82 fixedImageContainer->push_back(FixedImageType::New());
83 elastixObject->SetFixedImageContainer(fixedImageContainer);
85 const auto movingImageContainer = elx::ElastixBase::DataObjectContainerType::New();
86 movingImageContainer->push_back(MovingImageType::New());
87 elastixObject->SetMovingImageContainer(movingImageContainer);
95inline itk::OptimizerParameters<double>
98 assert(minValue < maxValue);
99 assert((maxValue - minValue) <= DBL_MAX);
101 itk::OptimizerParameters<double> parameters(numberOfParameters);
103 std::mt19937 randomNumberEngine;
105 std::generate_n(parameters.begin(), numberOfParameters, [&randomNumberEngine, minValue, maxValue] {
106 return std::uniform_real_distribution<>{ minValue, maxValue }(randomNumberEngine);
itk::OptimizerParameters< double > GeneratePseudoRandomParameters(const unsigned numberOfParameters, const double minValue, const double maxValue=1.0)
void ExpectAllKeysUnique(const TMap &map1, const TMap &map2)
Expect that all keys of both specified maps are unique.
TMap MakeMergedMap(TMap map1, const TMap &map2)
Makes a map by merging its two arguments together.
itk::SmartPointer< TElastix > CreateDefaultElastixObject()