Reduce machoness of macro definition in cost_functor_to_function_test.cc
Nuff said.
Change-Id: Ie38ca63bc0fb3b62f68ab330fc452e94071724aa
diff --git a/internal/ceres/cost_function_to_functor_test.cc b/internal/ceres/cost_function_to_functor_test.cc
index 52687ea..eb1d635 100644
--- a/internal/ceres/cost_function_to_functor_test.cc
+++ b/internal/ceres/cost_function_to_functor_test.cc
@@ -259,61 +259,61 @@
}
};
-#define TEST_BODY(NAME) \
- TEST(CostFunctionToFunctor, NAME) { \
- std::unique_ptr<CostFunction> cost_function( \
- new AutoDiffCostFunction< \
- CostFunctionToFunctor<2, PARAMETER_BLOCK_SIZES >, \
- 2, PARAMETER_BLOCK_SIZES>(new CostFunctionToFunctor< \
- 2, PARAMETER_BLOCK_SIZES >( \
- new AutoDiffCostFunction< \
- NAME##Functor, 2, PARAMETER_BLOCK_SIZES >( \
- new NAME##Functor)))); \
- \
-std::unique_ptr<CostFunction> actual_cost_function( \
- new AutoDiffCostFunction<NAME##Functor, 2, PARAMETER_BLOCK_SIZES >( \
- new NAME##Functor)); \
-ExpectCostFunctionsAreEqual(*cost_function, *actual_cost_function); \
-}
+// Check that AutoDiff(Functor1) == AutoDiff(CostToFunctor(AutoDiff(Functor1)))
+#define TEST_BODY(NAME) \
+ TEST(CostFunctionToFunctor, Functor1) { \
+ typedef AutoDiffCostFunction<Functor1, 2, PARAMETER_BLOCK_SIZES> \
+ CostFunction1; \
+ typedef CostFunctionToFunctor<2, PARAMETER_BLOCK_SIZES> FunctionToFunctor; \
+ typedef AutoDiffCostFunction<FunctionToFunctor, 2, PARAMETER_BLOCK_SIZES> \
+ CostFunction2; \
+ \
+ std::unique_ptr<CostFunction> cost_function(new CostFunction2( \
+ new FunctionToFunctor(new CostFunction1(new Functor1)))); \
+ \
+ std::unique_ptr<CostFunction> actual_cost_function( \
+ new CostFunction1(new Functor1)); \
+ ExpectCostFunctionsAreEqual(*cost_function, *actual_cost_function); \
+ }
#define PARAMETER_BLOCK_SIZES 2
-TEST_BODY(OneParameterBlock)
+TEST_BODY(OneParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2
-TEST_BODY(TwoParameterBlock)
+TEST_BODY(TwoParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2
-TEST_BODY(ThreeParameterBlock)
+TEST_BODY(ThreeParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2
-TEST_BODY(FourParameterBlock)
+TEST_BODY(FourParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2,2
-TEST_BODY(FiveParameterBlock)
+TEST_BODY(FiveParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2,2,2
-TEST_BODY(SixParameterBlock)
+TEST_BODY(SixParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2,2,2,2
-TEST_BODY(SevenParameterBlock)
+TEST_BODY(SevenParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2,2,2,2,2
-TEST_BODY(EightParameterBlock)
+TEST_BODY(EightParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2,2,2,2,2,2
-TEST_BODY(NineParameterBlock)
+TEST_BODY(NineParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#define PARAMETER_BLOCK_SIZES 2,2,2,2,2,2,2,2,2,2
-TEST_BODY(TenParameterBlock)
+TEST_BODY(TenParameterBlockFunctor)
#undef PARAMETER_BLOCK_SIZES
#undef TEST_BODY