Permalink
Browse files

test: Fix compile error for clang in unit tests

value_diff functions must be defined before they are used in the macros.
  • Loading branch information...
1 parent ad71c7e commit 6ef8b98bbf79fb950ade5858876653be8b05605c Zack Moratto committed May 3, 2012
View
@@ -88,6 +88,52 @@ void mismatch_queue(InputIterator1 first1, InputIterator1 last1, InputIterator2
}
}
+// Difference calculators
+template <typename ElemT, typename Elem2T>
+double value_diff(const vw::PixelMathBase<ElemT>& a, const vw::PixelMathBase<Elem2T>& b) {
+ BOOST_STATIC_ASSERT((boost::is_same<ElemT, Elem2T>::value));
+ typedef typename CompoundChannelType<ElemT>::type channel_type;
+ double acc = 0.0;
+ for( size_t c=0; c < PixelNumChannels<ElemT>::value; ++c ) {
+ channel_type const& a_x = compound_select_channel<channel_type const&>(a.impl(),c);
+ channel_type const& b_x = compound_select_channel<channel_type const&>(b.impl(),c);
+ double diff = double(a_x) - double(b_x);
+ acc += diff*diff;
+ }
+ return ::sqrt(acc);
+}
+
+template <typename Vec1T, typename Vec2T>
+double value_diff(const vw::VectorBase<Vec1T>& a, const vw::VectorBase<Vec2T>& b) {
+ BOOST_STATIC_ASSERT((boost::is_same<typename Vec1T::value_type,typename Vec2T::value_type>::value));
+ double acc = 0.0;
+ typename Vec2T::const_iterator it2 = b.impl().begin();
+ for (typename Vec1T::const_iterator it1 = a.impl().begin();
+ it1 != a.impl().end(); it1++ ) {
+ double diff = double(*it1) - double(*it2);
+ acc += diff*diff;
+ it2++;
+ }
+ return ::sqrt(acc);
+}
+
+template <typename T1, typename T2>
+double value_diff(const std::complex<T1>& a, const std::complex<T2>& b) {
+ return std::abs(std::complex<double>(a) - std::complex<double>(b));
+}
+
+template <typename T1, typename T2>
+struct both_are_arithmetic : boost::mpl::and_<boost::is_arithmetic<T1>, boost::is_arithmetic<T2> > {};
+
+template <typename T1, typename T2>
+typename boost::enable_if<both_are_arithmetic<T1,T2>, double>::type
+value_diff(const T1& a, const T2& b) {
+ BOOST_STATIC_ASSERT(boost::is_arithmetic<T1>::value);
+ BOOST_STATIC_ASSERT(boost::is_arithmetic<T2>::value);
+ return ::fabs(double(a) - double(b));
+}
+
+// Comparison classes
template <typename ImplT>
class CmpWorker {
public:
@@ -416,50 +462,6 @@ _CheckNDRange<CmpT> check_nd_range(const CmpT& cmp) {
#define EXPECT_MATRIX_NEAR(e, a, delta) EXPECT_SEQ_NEAR(e,a,delta)
#define ASSERT_MATRIX_NEAR(e, a, delta) ASSERT_SEQ_NEAR(e,a,delta)
-template <typename ElemT, typename Elem2T>
-double value_diff(const vw::PixelMathBase<ElemT>& a, const vw::PixelMathBase<Elem2T>& b) {
- BOOST_STATIC_ASSERT((boost::is_same<ElemT, Elem2T>::value));
- typedef typename CompoundChannelType<ElemT>::type channel_type;
- double acc = 0.0;
- for( size_t c=0; c < PixelNumChannels<ElemT>::value; ++c ) {
- channel_type const& a_x = compound_select_channel<channel_type const&>(a.impl(),c);
- channel_type const& b_x = compound_select_channel<channel_type const&>(b.impl(),c);
- double diff = double(a_x) - double(b_x);
- acc += diff*diff;
- }
- return ::sqrt(acc);
-}
-
-template <typename Vec1T, typename Vec2T>
-double value_diff(const vw::VectorBase<Vec1T>& a, const vw::VectorBase<Vec2T>& b) {
- BOOST_STATIC_ASSERT((boost::is_same<typename Vec1T::value_type,typename Vec2T::value_type>::value));
- double acc = 0.0;
- typename Vec2T::const_iterator it2 = b.impl().begin();
- for (typename Vec1T::const_iterator it1 = a.impl().begin();
- it1 != a.impl().end(); it1++ ) {
- double diff = double(*it1) - double(*it2);
- acc += diff*diff;
- it2++;
- }
- return ::sqrt(acc);
-}
-
-template <typename T1, typename T2>
-double value_diff(const std::complex<T1>& a, const std::complex<T2>& b) {
- return std::abs(std::complex<double>(a) - std::complex<double>(b));
-}
-
-template <typename T1, typename T2>
-struct both_are_arithmetic : boost::mpl::and_<boost::is_arithmetic<T1>, boost::is_arithmetic<T2> > {};
-
-template <typename T1, typename T2>
-typename boost::enable_if<both_are_arithmetic<T1,T2>, double>::type
-value_diff(const T1& a, const T2& b) {
- BOOST_STATIC_ASSERT(boost::is_arithmetic<T1>::value);
- BOOST_STATIC_ASSERT(boost::is_arithmetic<T2>::value);
- return ::fabs(double(a) - double(b));
-}
-
}} // namespace t
#endif
@@ -5,8 +5,6 @@
// __END_LICENSE__
-#include <gtest/gtest_VW.h>
-
#include <vw/Core/Exception.h>
#include <test/Helpers.h>
@@ -9,7 +9,6 @@
#include <fstream>
#include <sstream>
-#include <gtest/gtest_VW.h>
#include <vw/Core/Settings.h>
#include <vw/Core/ConfigParser.h>
#include <test/Helpers.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Core/TypeDeduction.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Image/BlockRasterize.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Image/ImageView.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Image/ImageView.h>
@@ -98,10 +98,9 @@ TYPED_TEST( MaskedViewTest, copy_mask ) {
// Test a copy mask where the input is a different channel type
ImageView< PixelRGB<uint8> > in_rgbu8(2,2);
- in(0,0) = PixelRGB<uint8>(9); in(1,0) = PixelRGB<uint8>(8);
- in(0,1) = PixelRGB<uint8>(1); in(1,1) = PixelRGB<uint8>(4);
- ImageView<PixelMask<PixelRGB<uint8> > > out_rgbu8 =
- copy_mask( in_rgbu8, this->a );
+ in_rgbu8(0,0) = PixelRGB<uint8>(9); in_rgbu8(1,0) = PixelRGB<uint8>(8);
+ in_rgbu8(0,1) = PixelRGB<uint8>(1); in_rgbu8(1,1) = PixelRGB<uint8>(4);
+ ImageView<PixelMask<PixelRGB<uint8> > > out_rgbu8 = copy_mask( in_rgbu8, this->a );
EXPECT_EQ( 2, out_rgbu8.cols() ); EXPECT_EQ( 2, out_rgbu8.rows() );
EXPECT_TRUE( is_valid(out_rgbu8(0,0)) );
EXPECT_TRUE( is_valid(out_rgbu8(1,0)) );
@@ -115,7 +114,7 @@ TYPED_TEST( MaskedViewTest, copy_mask ) {
mask(0,1) = PixelMask<uint8>(255); mask(1,1) = PixelMask<uint8>();
c = copy_mask(in, mask);
EXPECT_EQ( 2, c.cols() ); EXPECT_EQ( 2, c.rows() );
- EXPECT_FALSE is_valid(c(0,0)) );
+ EXPECT_FALSE( is_valid(c(0,0)) );
EXPECT_TRUE( is_valid(c(1,0)) );
EXPECT_TRUE( is_valid(c(0,1)) );
EXPECT_FALSE(is_valid(c(1,1)) );
@@ -253,5 +252,4 @@ TYPED_TEST( MaskedViewTest, create_apply_mask ) {
EXPECT_EQ( typename TestFixture::Px(2), e(1,0) );
EXPECT_EQ( typename TestFixture::Px(3), e(0,1) );
EXPECT_EQ( typename TestFixture::Px(4), e(1,1) );
-
}
@@ -125,29 +125,29 @@ TEST( PixelMath, SelfAssignment ) {
typedef PixelRGB<uint8> Px;
Px a(1,2,3), b(2,3,4);
a += 2;
- ASSERT_PIXEL_EQ( a, Px(3,4,5) );
+ EXPECT_VW_EQ( a, Px(3,4,5) );
a -= 2;
- ASSERT_PIXEL_EQ( a, Px(1,2,3) );
+ EXPECT_VW_EQ( a, Px(1,2,3) );
a *= 2;
- ASSERT_PIXEL_EQ( a, Px(2,4,6) );
+ EXPECT_VW_EQ( a, Px(2,4,6) );
a /= 2;
- ASSERT_PIXEL_EQ( a, Px(1,2,3) );
+ EXPECT_VW_EQ( a, Px(1,2,3) );
a += b;
- ASSERT_PIXEL_EQ( a, Px(3,5,7) );
+ EXPECT_VW_EQ( a, Px(3,5,7) );
a -= b;
- ASSERT_PIXEL_EQ( a, Px(1,2,3) );
+ EXPECT_VW_EQ( a, Px(1,2,3) );
a *= b;
- ASSERT_PIXEL_EQ( a, Px(2,6,12) );
+ EXPECT_VW_EQ( a, Px(2,6,12) );
a /= b;
- ASSERT_PIXEL_EQ( a, Px(1,2,3) );
+ EXPECT_VW_EQ( a, Px(1,2,3) );
(a += 2) += 2;
- ASSERT_PIXEL_EQ( a, Px(5,6,7) );
+ EXPECT_VW_EQ( a, Px(5,6,7) );
(a -= 2) -= 2;
- ASSERT_PIXEL_EQ( a, Px(1,2,3) );
+ EXPECT_VW_EQ( a, Px(1,2,3) );
(a *= 2) *= 2;
- ASSERT_PIXEL_EQ( a, Px(4,8,12) );
+ EXPECT_VW_EQ( a, Px(4,8,12) );
(a /= 2) /= 2;
- ASSERT_PIXEL_EQ( a, Px(1,2,3) );
+ EXPECT_VW_EQ( a, Px(1,2,3) );
}
TEST( PixelMath, ACOS ) { TEST_UNARY_MATH_FUNCTION(acos,0.5,1.0472); }
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Image/ImageView.h>
@@ -6,7 +6,6 @@
#include <cmath>
-#include <gtest/gtest_VW.h>
#include <vw/Math/EulerAngles.h>
#include <test/Helpers.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Math/Vector.h>
#include <vw/Math/Matrix.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Math/Matrix.h>
#include <vw/Math/Vector.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Core/Log.h>
#include <vw/Math/Vector.h>
@@ -4,8 +4,6 @@
// All Rights Reserved.
// __END_LICENSE__
-
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Math/ParticleSwarmOptimization.h>
@@ -6,7 +6,6 @@
// TestVector.h
-#include <gtest/gtest_VW.h>
#include <test/Helpers.h>
#include <vw/Math/Vector.h>

0 comments on commit 6ef8b98

Please sign in to comment.