|
| 1 | +/*========================================================================= |
| 2 | + * |
| 3 | + * Copyright NumFOCUS |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0.txt |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + * |
| 17 | + *=========================================================================*/ |
| 18 | + |
| 19 | +// First include the header file to be tested: |
| 20 | +#include "itkTransform.h" |
| 21 | + |
| 22 | +#include <gtest/gtest.h> |
| 23 | + |
| 24 | +namespace |
| 25 | +{ |
| 26 | +template <typename TParametersValueType, unsigned int NInputDimensions, unsigned int NOutputDimensions> |
| 27 | +class DerivedTransform : public itk::Transform<TParametersValueType, NInputDimensions, NOutputDimensions> |
| 28 | +{ |
| 29 | +public: |
| 30 | + ITK_DISALLOW_COPY_AND_MOVE(DerivedTransform); |
| 31 | + |
| 32 | + using Self = DerivedTransform; |
| 33 | + using Superclass = itk::Transform<TParametersValueType, NInputDimensions, NOutputDimensions>; |
| 34 | + using Pointer = itk::SmartPointer<Self>; |
| 35 | + |
| 36 | + itkNewMacro(Self); |
| 37 | + |
| 38 | +private: |
| 39 | + DerivedTransform() = default; |
| 40 | + |
| 41 | + using typename Superclass::FixedParametersType; |
| 42 | + using typename Superclass::InputPointType; |
| 43 | + using typename Superclass::JacobianType; |
| 44 | + using typename Superclass::OutputPointType; |
| 45 | + using typename Superclass::ParametersType; |
| 46 | + |
| 47 | + static constexpr const char * exceptionMessage = |
| 48 | + "This member function is not meant to be called during unit testing!"; |
| 49 | + |
| 50 | + void |
| 51 | + SetParameters(const ParametersType &) override |
| 52 | + { |
| 53 | + itkExceptionMacro(<< exceptionMessage); |
| 54 | + } |
| 55 | + |
| 56 | + void |
| 57 | + SetFixedParameters(const FixedParametersType &) override |
| 58 | + { |
| 59 | + itkExceptionMacro(<< exceptionMessage); |
| 60 | + } |
| 61 | + |
| 62 | + OutputPointType |
| 63 | + TransformPoint(const InputPointType &) const override |
| 64 | + { |
| 65 | + itkExceptionMacro(<< exceptionMessage); |
| 66 | + } |
| 67 | + |
| 68 | + void |
| 69 | + ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const override |
| 70 | + { |
| 71 | + itkExceptionMacro(<< exceptionMessage); |
| 72 | + } |
| 73 | +}; |
| 74 | +} // namespace |
| 75 | + |
| 76 | + |
| 77 | +// Tests that a transform derived from itk::Transform has empty Parameters and FixedParameters by default. |
| 78 | +TEST(Transform, HasEmptyParametersAndFixedParametersByDefault) |
| 79 | +{ |
| 80 | + const auto expectEmpty = [](const auto & transform) { |
| 81 | + EXPECT_TRUE(transform.GetParameters().empty()); |
| 82 | + EXPECT_TRUE(transform.GetFixedParameters().empty()); |
| 83 | + }; |
| 84 | + |
| 85 | + expectEmpty(*(DerivedTransform<float, 2, 2>::New())); |
| 86 | + expectEmpty(*(DerivedTransform<double, 3, 4>::New())); |
| 87 | +} |
0 commit comments