Skip to content
This repository
Browse code

test: Upgrade to VW GTest

This provides us a slightly modified gtest 1.6
  • Loading branch information...
commit 95efdafe1fc7c9fb95b2904000b917fc4581f786 1 parent c234602
Zack Moratto authored January 30, 2012
4  config/tests.am
@@ -10,10 +10,12 @@ GTEST_DIR = $(top_srcdir)/thirdparty/gtest
10 10
 libgtest_la_SOURCES = $(GTEST_DIR)/src/gtest-all.cc $(top_srcdir)/src/test/test_main.cc
11 11
 # this empty assignment prevents AM_LDFLAGS from applying to libgtest
12 12
 libgtest_la_LDFLAGS =
  13
+libgtest_la_LIBADD = @PKG_CORE_LIBS@ $(PKG_BOOST_FILESYSTEM_LIBS)
13 14
 
14 15
 check_LTLIBRARIES = libgtest.la
15 16
 
16  
-AM_CPPFLAGS += -DTEST_SRCDIR="\"$(top_srcdir)/$(subdir)\"" -I$(GTEST_DIR) -I$(GTEST_DIR)/include -g
  17
+AM_CPPFLAGS += -DTEST_SRCDIR="\"$(abs_top_srcdir)/$(subdir)\"" -DTEST_OBJDIR="\"$(abs_top_builddir)/$(subdir)\"" -isystem $(GTEST_DIR) -isystem $(GTEST_DIR)/include -g @PKG_CORE_CPPFLAGS@
  18
+
17 19
 LDADD = libgtest.la
18 20
 
19 21
 # This makes sure we're using the c++ linker
3  src/asp/Core/tests/Makefile.am
@@ -13,8 +13,9 @@ if MAKE_MODULE_CORE
13 13
 
14 14
 TestErodeView_SOURCES         = TestErodeView.cxx
15 15
 TestBlobIndexThreaded_SOURCES = TestBlobIndexThreaded.cxx
  16
+TestThreadedEdgeMask_SOURCES  = TestThreadedEdgeMask.cxx
16 17
 
17  
-TESTS = TestErodeView TestBlobIndexThreaded
  18
+TESTS = TestErodeView TestBlobIndexThreaded TestThreadedEdgeMask
18 19
 
19 20
 endif
20 21
 
3  src/asp/Core/tests/TestBlobIndexThreaded.cxx
@@ -4,8 +4,7 @@
4 4
 // All Rights Reserved.
5 5
 // __END_LICENSE__
6 6
 
7  
-
8  
-#include <gtest/gtest.h>
  7
+#include <test/Helpers.h>
9 8
 
10 9
 #include <vw/FileIO.h>
11 10
 #include <vw/Image.h>
3  src/asp/Core/tests/TestErodeView.cxx
@@ -4,8 +4,7 @@
4 4
 // All Rights Reserved.
5 5
 // __END_LICENSE__
6 6
 
7  
-
8  
-#include <gtest/gtest.h>
  7
+#include <test/Helpers.h>
9 8
 
10 9
 #include <vw/Image/ImageViewRef.h>
11 10
 #include <asp/Core/ErodeView.h>
3  src/asp/IsisIO/tests/TestEphemerisEquations.cxx
@@ -4,8 +4,7 @@
4 4
 // All Rights Reserved.
5 5
 // __END_LICENSE__
6 6
 
7  
-
8  
-#include <gtest/gtest.h>
  7
+#include <test/Helpers.h>
9 8
 
10 9
 #include <asp/IsisIO/PolyEquation.h>
11 10
 #include <asp/IsisIO/RPNEquation.h>
4  src/asp/IsisIO/tests/TestIsisAdjustCameraModel.cxx
@@ -4,12 +4,10 @@
4 4
 // All Rights Reserved.
5 5
 // __END_LICENSE__
6 6
 
7  
-
8  
-#include <gtest/gtest.h>
  7
+#include <test/Helpers.h>
9 8
 
10 9
 #include <asp/IsisIO/IsisAdjustCameraModel.h>
11 10
 #include <asp/IsisIO/IsisCameraModel.h>
12  
-#include <test/Helpers.h>
13 11
 #include <boost/foreach.hpp>
14 12
 
15 13
 using namespace vw;
4  src/asp/IsisIO/tests/TestIsisCameraModel.cxx
@@ -4,14 +4,12 @@
4 4
 // All Rights Reserved.
5 5
 // __END_LICENSE__
6 6
 
7  
-
8  
-#include <gtest/gtest.h>
  7
+#include <test/Helpers.h>
9 8
 
10 9
 #include <vw/Math/Vector.h>
11 10
 #include <vw/Core/Debugging.h>
12 11
 #include <asp/IsisIO/IsisCameraModel.h>
13 12
 #include <vw/Cartography/SimplePointImageManipulation.h>
14  
-#include <test/Helpers.h>
15 13
 #include <boost/foreach.hpp>
16 14
 
17 15
 // Additional Headers required for ISIS
574  src/test/Helpers.h
@@ -8,10 +8,13 @@
8 8
 #ifndef __VW_TESTS_CONFIG_TEST_H__
9 9
 #define __VW_TESTS_CONFIG_TEST_H__
10 10
 
  11
+#include <gtest/gtest_ASP.h>
11 12
 #include <cmath>
12 13
 #include <complex>
13 14
 #include <string>
14 15
 #include <boost/function.hpp>
  16
+#include <queue>
  17
+#include <cstdlib>
15 18
 
16 19
 #include <vw/config.h>
17 20
 #include <vw/Core/Log.h>
@@ -32,294 +35,417 @@
32 35
 #define HAS_CONFIG_FILE(x) DISABLED_ ## x
33 36
 #endif
34 37
 
  38
+namespace gi = ::testing::internal;
  39
+
  40
+namespace vw { namespace test { }}
  41
+namespace t  = vw::test;
  42
+
35 43
 namespace vw {
36 44
   namespace test {
37 45
 
38 46
 using namespace ::testing;
39 47
 
40  
-#ifndef TEST_SRCDIR
41  
-#error TEST_SRCDIR is not defined! Define it before including this header.
  48
+#ifndef TEST_OBJDIR
  49
+#error TEST_OBJDIR is not defined! Define it before including this header.
42 50
 #endif
43 51
 
44 52
 // Create a temporary filename that is unlinked when constructed and destructed
45 53
 class UnlinkName : public std::string {
46 54
   public:
47 55
     UnlinkName() {}
48  
-    UnlinkName(std::string base, std::string directory=TEST_SRCDIR);
  56
+    UnlinkName(const std::string& base, const std::string& directory=TEST_OBJDIR);
  57
+    UnlinkName(const char *base,        const std::string& directory=TEST_OBJDIR);
49 58
     ~UnlinkName();
50 59
 };
51 60
 
52  
-#define EXPECT_MATRIX_NEAR(val1, val2, delta)\
53  
-  EXPECT_PRED_FORMAT2(vw::test::MatrixHelper<double>(vw::test::NearImpl(#delta, delta)), val1, val2)
54  
-#define ASSERT_MATRIX_NEAR(val1, val2, delta)\
55  
-  ASSERT_PRED_FORMAT2(vw::test::MatrixHelper<double>(vw::test::NearImpl(#delta, delta)), val1, val2)
56  
-
57  
-#define EXPECT_MATRIX_DOUBLE_EQ(val1, val2)\
58  
-  EXPECT_PRED_FORMAT2(vw::test::MatrixHelper<double>(vw::test::ULPEq<double>()), val1, val2)
59  
-#define ASSERT_MATRIX_DOUBLE_EQ(val1, val2)\
60  
-  ASSERT_PRED_FORMAT2(vw::test::MatrixHelper<double>(vw::test::ULPEq<double>()), val1, val2)
61  
-
62  
-#define EXPECT_MATRIX_FLOAT_EQ(val1, val2)\
63  
-  EXPECT_PRED_FORMAT2(vw::test::MatrixHelper<float>(vw::test::ULPEq<float>()), val1, val2)
64  
-#define ASSERT_MATRIX_FLOAT_EQ(val1, val2)\
65  
-  ASSERT_PRED_FORMAT2(vw::test::MatrixHelper<float>(vw::test::ULPEq<float>()), val1, val2)
66  
-
67  
-#define EXPECT_VECTOR_NEAR(val1, val2, delta)\
68  
-  EXPECT_PRED_FORMAT2(vw::test::VectorHelper<double>(vw::test::NearImpl(#delta, delta)), val1, val2)
69  
-#define ASSERT_VECTOR_NEAR(val1, val2, delta)\
70  
-  ASSERT_PRED_FORMAT2(vw::test::VectorHelper<double>(vw::test::NearImpl(#delta, delta)), val1, val2)
71  
-
72  
-#define EXPECT_VECTOR_DOUBLE_EQ(val1, val2)\
73  
-  EXPECT_PRED_FORMAT2(vw::test::VectorHelper<double>(vw::test::ULPEq<double>()), val1, val2)
74  
-#define ASSERT_VECTOR_DOUBLE_EQ(val1, val2)\
75  
-  ASSERT_PRED_FORMAT2(vw::test::VectorHelper<double>(vw::test::ULPEq<double>()), val1, val2)
76  
-
77  
-#define EXPECT_VECTOR_FLOAT_EQ(val1, val2)\
78  
-  EXPECT_PRED_FORMAT2(vw::test::VectorHelper<float>(vw::test::ULPEq<float>()), val1, val2)
79  
-#define ASSERT_VECTOR_FLOAT_EQ(val1, val2)\
80  
-  ASSERT_PRED_FORMAT2(vw::test::VectorHelper<float>(vw::test::ULPEq<float>()), val1, val2)
81  
-
82  
-#define EXPECT_COMPLEX_MATRIX_NEAR(val1, val2, delta)\
83  
-  EXPECT_PRED_FORMAT2(vw::test::MatrixHelper<std::complex<double> >(vw::test::NearImpl(#delta, delta)), val1, val2)
84  
-#define ASSERT_COMPLEX_MATRIX_NEAR(val1, val2, delta)\
85  
-  ASSERT_PRED_FORMAT2(vw::test::MatrixHelper<std::complex<double> >(vw::test::NearImpl(#delta, delta)), val1, val2)
86  
-
87  
-
88  
-#define EXPECT_PIXEL_NEAR(val1, val2, delta)\
89  
-  EXPECT_PRED_FORMAT2(vw::test::PixelNearHelper(#delta, delta), val1, val2)
90  
-#define ASSERT_PIXEL_NEAR(val1, val2, delta)\
91  
-  ASSERT_PRED_FORMAT2(vw::test::PixelNearHelper(#delta, delta), val1, val2)
92  
-#define EXPECT_PIXEL_EQ(val1, val2)\
93  
-  EXPECT_PRED_FORMAT2(vw::test::PixelEqHelper(), val1, val2)
94  
-#define ASSERT_PIXEL_EQ(val1, val2)\
95  
-  ASSERT_PRED_FORMAT2(vw::test::PixelEqHelper(), val1, val2)
96  
-
97  
-template <typename ElemT>
98  
-inline double value_diff(const ElemT& a, const ElemT& b) {
99  
-  return std::fabs(a - b);
  61
+// A getenv with a default value
  62
+std::string getenv2(const char *key, const std::string& Default);
  63
+
  64
+// Fetch the seed we used. You should only need to do this if you're
  65
+// initializing a different random number generator (i.e. boost::rand48). Do
  66
+// NOT use this to reseed a global random number generator.
  67
+uint32 get_random_seed();
  68
+
  69
+// reduce the damage from using gtest internal bits, and make sure uint8 is
  70
+// seen as numeric.
  71
+template <typename T>
  72
+::std::string format(const T& x) {
  73
+  return PrintToString(_numeric(x));
100 74
 }
101 75
 
102  
-template <>
103  
-inline double value_diff(const std::complex<double>& a, const std::complex<double>& b) {
104  
-  return abs(a - b);
  76
+
  77
+// A version of std::mismatch that returns the set of differences rather than
  78
+// just the first
  79
+template <class InputIterator1, class InputIterator2, class Pred>
  80
+void mismatch_queue(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
  81
+                    std::queue<std::pair<InputIterator1, InputIterator2> >& answer,
  82
+                    const Pred& p)
  83
+{
  84
+  while ( first1!=last1 ) {
  85
+    if (!p(*first1, *first2))
  86
+      answer.push(std::make_pair(first1, first2));
  87
+    ++first1; ++first2;
  88
+  }
105 89
 }
106 90
 
107  
-template <typename ElemT>
108  
-class MatrixHelper {
109  
-  typedef boost::function<AssertionResult (const std::string& ename, const std::string& aname, const ElemT& expected, const ElemT& actual)> Pred2;
110  
-  const Pred2& p;
  91
+template <typename ImplT>
  92
+class CmpWorker {
111 93
   public:
112  
-  MatrixHelper(const Pred2& p) : p(p) {}
113  
-  AssertionResult operator()(const char* ename, const char* aname, Matrix<ElemT> expected, Matrix<ElemT> actual)
114  
-  {
115  
-    Message msg;
116  
-    bool failed = false;
117  
-
118  
-    if ( expected.rows() != actual.rows() ) {
119  
-      failed = true;
120  
-      msg << "Cannot compare " << ename << " and " << aname << ": Different number of rows (" << expected.rows() << " vs " << actual.rows() << ")";
121  
-    }
122  
-    if ( expected.cols() != actual.cols() ) {
123  
-      failed = true;
124  
-      msg << "Cannot compare " << ename << " and " << aname << ": Different number of cols (" << expected.cols() << " vs " << actual.cols() << ")";
125  
-    }
  94
+    inline ImplT& impl() { return static_cast<ImplT&>(*this); }
  95
+    inline ImplT const& impl() const { return static_cast<ImplT const&>(*this); }
126 96
 
127  
-    if (failed)
128  
-      return AssertionFailure(msg);
  97
+    template <typename T1, typename T2>
  98
+    bool operator()(const T1& e, const T2& a) const {return impl()(e, a);}
129 99
 
130  
-    for (size_t i = 0; i < expected.rows(); ++i) {
131  
-      for (size_t j = 0; j < expected.cols(); ++j) {
132  
-        const std::string idx = "(" + stringify(i) +  ","  + stringify(j) + ")";
133  
-        AssertionResult ret = p(ename + idx, aname + idx, expected(i,j), actual(i,j));
134  
-
135  
-        if (!ret) {
136  
-          if (failed)
137  
-            msg << "\n";
138  
-          failed = true;
139  
-          msg << ret.failure_message();
140  
-        }
141  
-      }
  100
+    template <typename T1, typename T2>
  101
+    Message what(const std::string& ename, const std::string& aname, const T1& e, const T2& a) const {
  102
+      return impl().what(ename, aname, e, a);
142 103
     }
  104
+};
143 105
 
144  
-    if (failed)
145  
-      return AssertionFailure(msg);
146  
-    return AssertionSuccess();
147  
-  }
  106
+class CmpEqual : public CmpWorker<CmpEqual> {
  107
+  public:
  108
+    template <typename T1, typename T2>
  109
+    bool operator()(const T1& a, const T2& b) const { return a == b; }
  110
+
  111
+    template <typename T1, typename T2>
  112
+    Message what(const std::string& ename, const std::string& aname, const T1& e, const T2& a) const {
  113
+      return Message() << gi::EqFailure(ename.c_str(), aname.c_str(), t::format(e), t::format(a), false).message();
  114
+    }
148 115
 };
149 116
 
150  
-template <typename ElemT>
151  
-class VectorHelper {
152  
-  typedef boost::function<AssertionResult (const std::string& ename, const std::string& aname, const ElemT& expected, const ElemT& actual)> Pred2;
153  
-  const Pred2& p;
  117
+class CmpTypeEqual : public CmpWorker<CmpTypeEqual> {
154 118
   public:
155  
-  VectorHelper(const Pred2& p) : p(p) {}
156  
-  AssertionResult operator()(const char* ename, const char* aname, Vector<ElemT> expected, Vector<ElemT> actual)
157  
-  {
158  
-    Message msg;
159  
-    bool failed = false;
160  
-
161  
-    if ( expected.size() != actual.size() )
162  
-      return AssertionFailure(Message() << "Cannot compare " << ename << " and " << aname << ": Different size (" << expected.size() << " vs " << actual.size() << ")");
163  
-
164  
-    for (size_t i = 0; i < expected.size(); ++i) {
165  
-      const std::string idx = "(" + stringify(i) + ")";
166  
-      AssertionResult ret = p(ename + idx, aname + idx, expected(i), actual(i));
167  
-
168  
-      if (!ret) {
169  
-        if (failed)
170  
-          msg << "\n";
171  
-        failed = true;
172  
-        msg << ret.failure_message();
173  
-      }
  119
+    template <typename T1, typename T2>
  120
+    bool operator()(const T1& a, const T2& b) const {
  121
+      return boost::is_same<T1,T2>::value && a == b;
174 122
     }
175 123
 
176  
-    if (failed)
177  
-      return AssertionFailure(msg);
178  
-    return AssertionSuccess();
179  
-  }
  124
+    template <typename T1, typename T2>
  125
+    Message what(const std::string& ename, const std::string& aname, const T1& e, const T2& a) const {
  126
+      if (!boost::is_same<T1,T2>::value)
  127
+        return Message() << ename << " and " << aname << " are not the same type";
  128
+      return Message() << gi::EqFailure(ename.c_str(), aname.c_str(), t::format(e), t::format(a), false).message();
  129
+    }
180 130
 };
181 131
 
182  
-class NearImpl {
  132
+class CmpNear : public CmpWorker<CmpNear> {
183 133
     const char *dexpr;
184  
-    double delta;
  134
+    const double& delta;
185 135
   public:
186  
-    NearImpl(const char *dexpr = "0", double delta = 0) : dexpr(dexpr), delta(delta) {}
187  
-    template <typename ElemT>
188  
-    AssertionResult operator()(const std::string& ename, const std::string& aname, const ElemT& expected, const ElemT& actual) {
189  
-      const double diff = value_diff(expected, actual);
190  
-      if (diff <= delta)
191  
-        return AssertionSuccess();
  136
+    CmpNear(const char* dexpr, const double& delta) : dexpr(dexpr), delta(delta) {}
192 137
 
  138
+    template <typename T1, typename T2>
  139
+    bool operator()(const T1& a, const T2& b) const { return value_diff(a, b) <= delta; }
  140
+
  141
+    template <typename T1, typename T2>
  142
+    Message what(const std::string& ename, const std::string& aname, const T1& e, const T2& a) const {
193 143
       Message msg;
194 144
       msg << "The difference between "
195 145
           << ename   << " and " << aname
196  
-          << " is "  << diff << ", which exceeds " << dexpr << ", where\n"
197  
-          << ename << " evaluates to " << expected << ",\n"
198  
-          << aname << " evaluates to " << actual
199  
-          << ", and\n" << dexpr << " evaluates to " << delta << ".";
200  
-      return AssertionFailure(msg);
  146
+          << " is "  << t::format(value_diff(e, a))
  147
+          << ", which exceeds " << dexpr << ", where\n"
  148
+          << ename << " evaluates to " << t::format(e) << ",\n"
  149
+          << aname << " evaluates to " << t::format(a)
  150
+          << ", and\n" << dexpr << " evaluates to " << t::format(delta) << ".";
  151
+      return msg;
201 152
     }
202 153
 };
203 154
 
204 155
 #if 0
205  
-EXPECT_FLOAT_EQ
206  
-
207  
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
  156
+template <typename ExpectT>
  157
+struct CmpULP : public CmpWorker<CmpULP<ExpectT> > {
  158
+  BOOST_STATIC_ASSERT(boost::is_floating_point<ExpectT>::value);
  159
+  public:
  160
+    template <typename ActualT>
  161
+    bool operator()(const ExpectT& a, const ActualT& b) const {
  162
+      const gi::FloatingPoint<ExpectT> lhs(a), rhs(b);
  163
+      return lhs.AlmostEquals(rhs);
  164
+    }
208 165
 
209  
-AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,
210  
-                                         const char* actual_expression,
211  
-                                         RawType expected,
212  
-                                         RawType actual) {
  166
+    template <typename ActualT>
  167
+    Message what(const std::string& ename, const std::string& aname, const ExpectT& e, const ActualT& a) const {
  168
+      std::ostringstream es, as;
  169
+      es << std::setprecision(std::numeric_limits<ExpectT>::digits10 + 2) << e;
  170
+      as << std::setprecision(std::numeric_limits<ExpectT>::digits10 + 2) << a;
  171
+      return Message() << gi::EqFailure(ename.c_str(), aname.c_str(), es.str(), as.str(), false);
  172
+    }
  173
+};
213 174
 #endif
214 175
 
215  
-template <typename ExpectedT>
216  
-class ULPEq {
  176
+template <typename CmpT>
  177
+class _CheckOne {
  178
+    const CmpT& cmp;
217 179
   public:
218  
-    ULPEq() {}
219  
-    template <typename ElemT>
220  
-    AssertionResult operator()(const std::string& ename, const std::string& aname, const ExpectedT& expected, const ElemT& actual) {
221  
-      return ::testing::internal::CmpHelperFloatingPointEQ<ExpectedT>(ename.c_str(), aname.c_str(), expected, actual);
  180
+    _CheckOne() : cmp(CmpT()) {}
  181
+    _CheckOne(const CmpT& cmp) : cmp(cmp) {}
  182
+
  183
+    template <typename ExpectT, typename ActualT>
  184
+    AssertionResult operator()(const char* ename, const char* aname, const ExpectT& e, const ActualT& a) const
  185
+    {
  186
+      if (cmp(e, a))
  187
+        return AssertionSuccess();
  188
+      return AssertionFailure() << cmp.what(ename, aname, e, a);
222 189
     }
223 190
 };
  191
+template <typename CmpT>
  192
+_CheckOne<CmpT> check_one(const CmpT& cmp) {
  193
+  return _CheckOne<CmpT>(cmp);
  194
+}
  195
+
  196
+template <typename CmpT>
  197
+class _CheckRange {
  198
+    const CmpT& cmp;
  199
+  public:
  200
+    _CheckRange() : cmp(CmpT()) {}
  201
+    _CheckRange(const CmpT& cmp) : cmp(cmp) {}
  202
+
  203
+    template <typename Range1T, typename Range2T>
  204
+    AssertionResult operator()(const char* ename, const char* aname,
  205
+                               const Range1T& e, const Range2T& a) const
  206
+    {
  207
+      if (a.size() != e.size())
  208
+        return AssertionFailure()
  209
+                << "Iterator ranges (" << ename << ") and (" << aname
  210
+                << ") represent different-sized ranges.";
  211
+
  212
+      typedef std::pair<typename Range1T::const_iterator, typename Range2T::const_iterator> pair_t;
224 213
 
225  
-class PixelNearHelper {
226  
-  NearImpl p;
227  
-
228  
- public:
229  
-  PixelNearHelper(const char *dexpr, double delta ) : p(dexpr,delta) {}
230  
-
231  
-  template <class T1, class T2>
232  
-  AssertionResult operator()( const char* ename, const char* aname,
233  
-                              PixelMathBase<T1> const& expected,
234  
-                              PixelMathBase<T2> const& actual ) {
235  
-    BOOST_STATIC_ASSERT( (boost::is_same<T1,T2>::value) );
236  
-    Message msg;
237  
-    bool failed = false;
238  
-
239  
-    for ( size_t i = 0; i < CompoundNumChannels<T1>::value; i++ ) {
240  
-      const std::string idx = "["+stringify(i)+"]";
241  
-      AssertionResult ret = p( ename+idx, aname+idx,
242  
-                               expected.impl()(i), actual.impl()(i));
243  
-
244  
-      if (!ret) {
245  
-        if (failed)
246  
-          msg << "\n";
247  
-        failed = true;
248  
-        msg << ret.failure_message();
  214
+      std::queue<pair_t> ret;
  215
+      mismatch_queue(e.begin(), e.end(), a.begin(), ret, cmp);
  216
+
  217
+      if (ret.empty())
  218
+        return AssertionSuccess();
  219
+
  220
+      Message msg;
  221
+      bool need_newline = false;
  222
+      while (!ret.empty()) {
  223
+        const pair_t& r = ret.front();
  224
+        const std::string idx = "[" + stringify(std::distance(e.begin(), r.first)) + "]";
  225
+        if (need_newline)
  226
+          msg << std::endl;
  227
+        msg << cmp.what(ename + idx, aname + idx, *(r.first), *(r.second));
  228
+        need_newline = true;
  229
+        ret.pop();
249 230
       }
  231
+      return AssertionFailure(msg);
250 232
     }
251 233
 
252  
-    if (failed)
253  
-      return AssertionFailure(msg);
254  
-    return AssertionSuccess();
255  
-  }
  234
+    template <typename Iter1T, typename Iter2T>
  235
+    AssertionResult operator()(const char* e0name, const char* /*e1name*/,
  236
+                               const char* a0name, const char* /*a1name*/,
  237
+                               const Iter1T& e0, const Iter1T& e1,
  238
+                               const Iter2T& a0, const Iter2T& a1) const
  239
+    {
  240
+      return this->operator()(e0name, a0name, boost::make_iterator_range(e0, e1), boost::make_iterator_range(a0, a1));
  241
+    }
256 242
 };
257 243
 
258  
-template <typename ElemT>
259  
-inline AssertionResult comp_helper( const std::string& ename, const std::string& aname,
260  
-                                    const ElemT& expected, const ElemT& actual ) {
261  
-  return ::testing::internal::CmpHelperEQ(ename.c_str(), aname.c_str(), expected, actual);
  244
+template <typename CmpT>
  245
+_CheckRange<CmpT> check_range(const CmpT& cmp) {
  246
+  return _CheckRange<CmpT>(cmp);
262 247
 }
263 248
 
264  
-template <>
265  
-inline AssertionResult comp_helper<float>( const std::string& ename, const std::string& aname,
266  
-                                           const float& expected, const float& actual ) {
267  
-  return ::testing::internal::CmpHelperFloatingPointEQ<float>(ename.c_str(), aname.c_str(), expected, actual);
268  
-}
  249
+template <typename CmpT>
  250
+class _CheckNDRange {
  251
+    const CmpT& cmp;
269 252
 
270  
-template <>
271  
-inline AssertionResult comp_helper<double>( const std::string& ename, const std::string& aname,
272  
-                                            const double& expected, const double& actual ) {
273  
-  return ::testing::internal::CmpHelperFloatingPointEQ<double>(ename.c_str(), aname.c_str(), expected, actual);
274  
-}
  253
+    typedef Vector<size_t, 0> SVec;
275 254
 
276  
-template <>
277  
-inline AssertionResult comp_helper<uint8>( const std::string& ename, const std::string& aname,
278  
-                                           const uint8& expected, const uint8& actual ) {
  255
+    template <typename T>
  256
+    SVec size_helper(const MatrixBase<T>& m) {return Vector<size_t, 2>(m.impl().rows(), m.impl().cols());}
279 257
 
280  
-  if ( expected == actual )
281  
-    return AssertionSuccess();
  258
+    template <typename T>
  259
+    SVec size_helper(const ImageViewBase<T>& m) {return Vector<size_t, 3>(m.impl().planes(), m.impl().rows(), m.impl().cols());}
282 260
 
283  
-  Message msg;
284  
-  msg << "Value of: " << aname << "\n"
285  
-      << "  Actual: " << int(actual) << "\n"
286  
-      << "Expected: " << ename << "\n"
287  
-      << "Which is: " << int(expected) << "\n";
288  
-  return AssertionFailure(msg);
289  
-}
  261
+    template <typename T>
  262
+    SVec size_helper(const VectorBase<T>& m) {return m.size();}
290 263
 
291  
-class PixelEqHelper {
292  
-
293  
- public:
294  
-  PixelEqHelper() {}
295  
-
296  
-  template <class T1, class T2>
297  
-  AssertionResult operator()( const char* ename, const char* aname,
298  
-                              PixelMathBase<T1> const& expected,
299  
-                              PixelMathBase<T2> const& actual ) {
300  
-    BOOST_STATIC_ASSERT( (boost::is_same<T1,T2>::value) );
301  
-    Message msg;
302  
-    bool failed = false;
303  
-
304  
-    for ( size_t i = 0; i < CompoundNumChannels<T1>::value; i++ ) {
305  
-      const std::string idx = "["+stringify(i)+"]";
306  
-      AssertionResult ret = comp_helper( ename+idx, aname+idx,
307  
-                                         expected.impl()(i), actual.impl()(i) );
308  
-
309  
-      if (!ret) {
310  
-        if (failed)
311  
-          msg << "\n";
312  
-        failed = true;
313  
-        msg << ret.failure_message();
  264
+    SVec stride_from_size(const SVec& size) {
  265
+      SVec stride(size.size());
  266
+      stride(size.size()-1) = 1;
  267
+      for (ssize_t i = stride.size()-2; i >= 0; --i)
  268
+        stride[i] = size[i+1] * stride[i+1];
  269
+      return stride;
  270
+    }
  271
+
  272
+    template <typename IterT1>
  273
+    std::string to_idx(const SVec& stride, const IterT1& begin, const IterT1& wrong) {
  274
+      std::ostringstream ss;
  275
+      ss << "[";
  276
+      bool comma = false;
  277
+      ssize_t d = std::distance(begin, wrong);
  278
+      for (size_t i = 0; i < stride.size(); ++i) {
  279
+        if (comma)
  280
+          ss << ',';
  281
+        ss << size_t(d / stride[i]);
  282
+        d = d % stride[i];
  283
+        comma = true;
314 284
       }
  285
+      ss << "]";
  286
+      return ss.str();
315 287
     }
316 288
 
317  
-    if (failed)
  289
+  public:
  290
+    _CheckNDRange() : cmp(CmpT()) {}
  291
+    _CheckNDRange(const CmpT& cmp) : cmp(cmp) {}
  292
+
  293
+    template <typename T1, typename T2>
  294
+    AssertionResult operator()(const char* ename, const char* aname, const T1& e, const T2& a)
  295
+    {
  296
+      SVec esize = size_helper(e), asize = size_helper(a);
  297
+
  298
+      if ( esize != asize )
  299
+        return AssertionFailure() << "Cannot compare " << ename << " and " << aname << ": Different size: "
  300
+                                  << esize << " != " << asize;
  301
+
  302
+      typedef std::pair<typename T1::const_iterator, typename T2::const_iterator> pair_t;
  303
+      std::queue<pair_t> ret;
  304
+      mismatch_queue(e.begin(), e.end(), a.begin(), ret, cmp);
  305
+
  306
+      if (ret.empty())
  307
+        return AssertionSuccess();
  308
+
  309
+      SVec stride = stride_from_size(esize);
  310
+
  311
+      Message msg;
  312
+      bool need_newline = false;
  313
+      while (!ret.empty()) {
  314
+        const pair_t& r = ret.front();
  315
+        const std::string idx = to_idx(stride, e.begin(), r.first);
  316
+        if (need_newline)
  317
+          msg << std::endl;
  318
+        msg << cmp.what(ename + idx, aname + idx, *(r.first), *(r.second));
  319
+        need_newline = true;
  320
+        ret.pop();
  321
+      }
318 322
       return AssertionFailure(msg);
319  
-    return AssertionSuccess();
320  
-  }
  323
+    }
321 324
 };
322 325
 
323  
-}} // namespace vw::test
  326
+template <typename CmpT>
  327
+_CheckNDRange<CmpT> check_nd_range(const CmpT& cmp) {
  328
+  return _CheckNDRange<CmpT>(cmp);
  329
+}
  330
+
  331
+#define EXPECT_RANGE_EQ(expect0, expect1, actual0, actual1) \
  332
+  EXPECT_PRED_FORMAT4(t::check_range(t::CmpEqual()), expect0, expect1, actual0, actual1)
  333
+#define ASSERT_RANGE_EQ(expect0, expect1, actual0, actual1) \
  334
+  ASSERT_PRED_FORMAT4(t::check_range(t::CmpEqual()), expect0, expect1, actual0, actual1)
  335
+#define EXPECT_RANGE_NEAR(expect0, expect1, actual0, actual1, delta) \
  336
+  EXPECT_PRED_FORMAT4(t::check_range(t::CmpNear(#delta, delta)), expect0, expect1, actual0, actual1)
  337
+#define ASSERT_RANGE_NEAR(expect0, expect1, actual0, actual1, delta) \
  338
+  ASSERT_PRED_FORMAT4(t::check_range(t::CmpNear(#delta, delta)), expect0, expect1, actual0, actual1)
  339
+
  340
+#define EXPECT_SEQ_EQ(expect, actual)\
  341
+  EXPECT_PRED_FORMAT2(t::check_nd_range(t::CmpEqual()), expect, actual)
  342
+#define ASSERT_SEQ_EQ(expect, actual)\
  343
+  ASSERT_PRED_FORMAT2(t::check_nd_range(t::CmpEqual()), expect, actual)
  344
+#define EXPECT_SEQ_NEAR(expect, actual, delta)\
  345
+  EXPECT_PRED_FORMAT2(t::check_nd_range(t::CmpNear(#delta, delta)), expect, actual)
  346
+#define ASSERT_SEQ_NEAR(expect, actual, delta)\
  347
+  ASSERT_PRED_FORMAT2(t::check_nd_range(t::CmpNear(#delta, delta)), expect, actual)
  348
+
  349
+#define EXPECT_VECTOR_EQ(expect, actual)\
  350
+  EXPECT_PRED_FORMAT2(t::check_range(t::CmpEqual()), expect, actual)
  351
+#define ASSERT_VECTOR_EQ(expect, actual)\
  352
+  ASSERT_PRED_FORMAT2(t::check_range(t::CmpEqual()), expect, actual)
  353
+#define EXPECT_VECTOR_NEAR(expect, actual, delta)\
  354
+  EXPECT_PRED_FORMAT2(t::check_range(t::CmpNear(#delta, delta)), expect, actual)
  355
+#define ASSERT_VECTOR_NEAR(expect, actual, delta)\
  356
+  ASSERT_PRED_FORMAT2(t::check_range(t::CmpNear(#delta, delta)), expect, actual)
  357
+
  358
+#define EXPECT_TYPE_EQ( expect, actual )\
  359
+  EXPECT_PRED_FORMAT2(t::check_one(t::CmpTypeEqual()), expect, actual )
  360
+#define ASSERT_TYPE_EQ( expect, actual )\
  361
+  ASSERT_PRED_FORMAT2(t::check_one(t::CmpTypeEqual()), expect, actual )
  362
+
  363
+#define EXPECT_PIXEL_NEAR(expect, actual, delta)\
  364
+  EXPECT_PRED_FORMAT2(t::check_one(t::CmpNear(#delta, delta)), expect, actual)
  365
+#define ASSERT_PIXEL_NEAR(expect, actual, delta)\
  366
+  ASSERT_PRED_FORMAT2(t::check_one(t::CmpNear(#delta, delta)), expect, actual)
  367
+
  368
+#define EXPECT_VW_EQ(expect, actual)\
  369
+  EXPECT_PRED_FORMAT2(t::check_one(t::CmpTypeEqual()), expect, actual)
  370
+#define ASSERT_VW_EQ(expect, actual)\
  371
+  ASSERT_PRED_FORMAT2(t::check_one(t::CmpTypeEqual()), expect, actual)
  372
+
  373
+#define VW_TEST_THROW_(statement, expected_exception, expected_substr, fail) \
  374
+  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  375
+  if (::testing::internal::ConstCharPtr gtest_msg = "") { \
  376
+    bool gtest_caught_expected = false; \
  377
+    try { \
  378
+      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  379
+    } \
  380
+    catch (expected_exception const& e) { \
  381
+      gtest_caught_expected = true; \
  382
+      GTEST_PRED_FORMAT2_(t::IsSubstring, expected_substr, e.what(), fail);\
  383
+    } \
  384
+    catch (...) { \
  385
+      gtest_msg.value = \
  386
+          "Expected: " #statement " throws an exception of type " \
  387
+          #expected_exception ".\n  Actual: it throws a different type."; \
  388
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
  389
+    } \
  390
+    if (!gtest_caught_expected) { \
  391
+      gtest_msg.value = \
  392
+          "Expected: " #statement " throws an exception of type " \
  393
+          #expected_exception ".\n  Actual: it throws nothing."; \
  394
+      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
  395
+    } \
  396
+  } else \
  397
+    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
  398
+      fail(gtest_msg.value)
  399
+
  400
+// these are unlikely to work right in death tests or other weird circumstances.
  401
+#define EXPECT_THROW_MSG(statement, expected_exception, expected_substr) \
  402
+  VW_TEST_THROW_(statement, expected_exception, expected_substr, GTEST_NONFATAL_FAILURE_)
  403
+#define ASSERT_THROW_MSG(statement, expected_exception, expected_substr) \
  404
+  VW_TEST_THROW_(statement, expected_exception, expected_substr, GTEST_FATAL_FAILURE_)
  405
+
  406
+// DEPRECATED
  407
+#define EXPECT_MATRIX_FLOAT_EQ(e, a)          EXPECT_MATRIX_NEAR(e, a, 1e20)
  408
+#define EXPECT_MATRIX_DOUBLE_EQ(e, a)         EXPECT_MATRIX_NEAR(e, a, 1e45)
  409
+#define EXPECT_COMPLEX_MATRIX_NEAR(e, a, d)   EXPECT_MATRIX_NEAR(e, a, d)
  410
+#define EXPECT_VECTOR_FLOAT_EQ(e, a)          EXPECT_VECTOR_NEAR(e, a, 1e20)
  411
+#define EXPECT_VECTOR_DOUBLE_EQ(e, a)         EXPECT_VECTOR_NEAR(e, a, 1e45)
  412
+#define EXPECT_PIXEL_EQ(e, a)                 EXPECT_TYPE_EQ(e,a)
  413
+#define ASSERT_PIXEL_EQ(e, a)                 ASSERT_TYPE_EQ(e,a)
  414
+#define EXPECT_MATRIX_EQ(e, a)                EXPECT_SEQ_EQ(e,a)
  415
+#define ASSERT_MATRIX_EQ(e, a)                ASSERT_SEQ_EQ(e,a)
  416
+#define EXPECT_MATRIX_NEAR(e, a, delta)       EXPECT_SEQ_NEAR(e,a,delta)
  417
+#define ASSERT_MATRIX_NEAR(e, a, delta)       ASSERT_SEQ_NEAR(e,a,delta)
  418
+
  419
+template <typename ElemT, typename Elem2T>
  420
+double value_diff(const vw::PixelMathBase<ElemT>& a, const vw::PixelMathBase<Elem2T>& b) {
  421
+  BOOST_STATIC_ASSERT((boost::is_same<ElemT, Elem2T>::value));
  422
+  typedef typename CompoundChannelType<ElemT>::type channel_type;
  423
+  double acc = 0.0;
  424
+  for( size_t c=0; c < PixelNumChannels<ElemT>::value; ++c ) {
  425
+    channel_type const& a_x = compound_select_channel<channel_type const&>(a.impl(),c);
  426
+    channel_type const& b_x = compound_select_channel<channel_type const&>(b.impl(),c);
  427
+    double diff = double(a_x) - double(b_x);
  428
+    acc += diff*diff;
  429
+  }
  430
+  return ::sqrt(acc);
  431
+}
  432
+
  433
+template <typename T1, typename T2>
  434
+double value_diff(const std::complex<T1>& a, const std::complex<T2>& b) {
  435
+  return std::abs(std::complex<double>(a) - std::complex<double>(b));
  436
+}
  437
+
  438
+template <typename T1, typename T2>
  439
+struct both_are_arithmetic : boost::mpl::and_<boost::is_arithmetic<T1>, boost::is_arithmetic<T2> > {};
  440
+
  441
+template <typename T1, typename T2>
  442
+typename boost::enable_if<both_are_arithmetic<T1,T2>, double>::type
  443
+value_diff(const T1& a, const T2& b) {
  444
+  BOOST_STATIC_ASSERT(boost::is_arithmetic<T1>::value);
  445
+  BOOST_STATIC_ASSERT(boost::is_arithmetic<T2>::value);
  446
+  return ::fabs(double(a) - double(b));
  447
+}
  448
+
  449
+}} // namespace t
324 450
 
325 451
 #endif
75  src/test/test_main.cc
@@ -5,13 +5,82 @@
5 5
 // __END_LICENSE__
6 6
 
7 7
 
8  
-#include <gtest/gtest.h>
  8
+#include <gtest/gtest_ASP.h>
9 9
 #include <test/Helpers.h>
10 10
 #include <vw/Core/Settings.h>
11 11
 
  12
+#include <boost/filesystem/operations.hpp>
  13
+namespace fs = boost::filesystem;
  14
+
  15
+namespace {
  16
+  vw::uint32 SEED;
  17
+}
  18
+
12 19
 int main(int argc, char **argv) {
13 20
   // Disable the user's config file
14 21
   vw::vw_settings().set_rc_filename("");
15  
-  testing::InitGoogleTest(&argc, argv);
16  
-  return RUN_ALL_TESTS();
  22
+  ::testing::InitGoogleTest(&argc, argv);
  23
+
  24
+  // Default to the "threadsafe" style because we can't delete our singletons
  25
+  // yet; this style of test launches a new process, so the singletons are
  26
+  // fresh.
  27
+  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
  28
+
  29
+  if (getenv("VW_DEBUG")) {
  30
+    vw::vw_log().console_log().rule_set().add_rule(vw::VerboseDebugMessage, "*");
  31
+  }
  32
+
  33
+  // TODO: Make it so the seed is settable so we can reproduce failures in
  34
+  // probabilistic algorithms. This uses clock() instead of time() because
  35
+  // clock() (being measured in "processor ticks" instead of seconds) is likely
  36
+  // to exhibit more variation when tests are run many times in a short time
  37
+  // span.
  38
+  SEED = boost::numeric_cast<unsigned int>(clock());
  39
+  std::srand(SEED);
  40
+
  41
+  fs::path start_dir(TEST_SRCDIR);
  42
+
  43
+  fs::current_path(start_dir);
  44
+  VW_ASSERT(fs::equivalent(fs::current_path(), start_dir),
  45
+            vw::LogicErr() << "Could not change the working directory to " << start_dir);
  46
+
  47
+  int ret = RUN_ALL_TESTS();
  48
+  fs::path end_dir = fs::current_path();
  49
+
  50
+  VW_ASSERT( fs::equivalent(start_dir, end_dir),
  51
+             vw::LogicErr() << "Something changed the working directory");
  52
+  return ret;
  53
+}
  54
+
  55
+namespace vw {
  56
+namespace test {
  57
+
  58
+UnlinkName::UnlinkName(const std::string& base, const std::string& directory)
  59
+  : std::string(directory + "/" + base) {
  60
+
  61
+  VW_ASSERT(!directory.empty(), ArgumentErr() << "An empty directory path is dangerous");
  62
+  fs::remove_all(this->c_str());
  63
+}
  64
+
  65
+UnlinkName::UnlinkName(const char *base, const std::string& directory)
  66
+  : std::string(directory + "/" + base) {
  67
+
  68
+  VW_ASSERT(!directory.empty(), ArgumentErr() << "An empty directory path is dangerous");
  69
+  fs::remove_all(this->c_str());
  70
+}
  71
+
  72
+UnlinkName::~UnlinkName() {
  73
+  if (!this->empty())
  74
+    fs::remove_all(this->c_str());
  75
+}
  76
+
  77
+std::string getenv2(const char *key, const std::string& Default) {
  78
+  const char *val = getenv(key);
  79
+  return val ? val : Default;
17 80
 }
  81
+
  82
+vw::uint32 get_random_seed() {
  83
+  return SEED;
  84
+}
  85
+
  86
+}} // namespace vw::test
32  thirdparty/gtest/CHANGES
... ...
@@ -1,3 +1,35 @@
  1
+Changes for 1.6.0:
  2
+
  3
+* New feature: ADD_FAILURE_AT() for reporting a test failure at the
  4
+  given source location -- useful for writing testing utilities.
  5
+* New feature: the universal value printer is moved from Google Mock
  6
+  to Google Test.
  7
+* New feature: type parameters and value parameters are reported in
  8
+  the XML report now.
  9
+* A gtest_disable_pthreads CMake option.
  10
+* Colored output works in GNU Screen sessions now.
  11
+* Parameters of value-parameterized tests are now printed in the
  12
+  textual output.
  13
+* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are
  14
+  now correctly reported.
  15
+* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to
  16
+  ostream.
  17
+* More complete handling of exceptions.
  18
+* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter
  19
+  name is already used by another library.
  20
+* --gtest_catch_exceptions is now true by default, allowing a test
  21
+  program to continue after an exception is thrown.
  22
+* Value-parameterized test fixtures can now derive from Test and
  23
+  WithParamInterface<T> separately, easing conversion of legacy tests.
  24
+* Death test messages are clearly marked to make them more
  25
+  distinguishable from other messages.
  26
+* Compatibility fixes for Android, Google Native Client, MinGW, HP UX,
  27
+  PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear),
  28
+  IBM XL C++ (Visual Age C++), and C++0x.
  29
+* Bug fixes and implementation clean-ups.
  30
+* Potentially incompatible changes: disables the harmful 'make install'
  31
+  command in autotools.
  32
+
1 33
 Changes for 1.5.0:
2 34
 
3 35
  * New feature: assertions can be safely called in multiple threads
1  thirdparty/gtest/CONTRIBUTORS
@@ -21,6 +21,7 @@ Manuel Klimek <klimek@google.com>
21 21
 Markus Heule <markus.heule@gmail.com>
22 22
 Mika Raento <mikie@iki.fi>
23 23
 Miklós Fazekas <mfazekas@szemafor.com>
  24
+Pasi Valminen <pasi.valminen@gmail.com>
24 25
 Patrick Hanna <phanna@google.com>
25 26
 Patrick Riley <pfr@google.com>
26 27
 Peter Kaminski <piotrk@google.com>
21  thirdparty/gtest/README
@@ -171,7 +171,7 @@ workflow starts with:
171 171
 If you want to build Google Test's samples, you should replace the
172 172
 last command with
173 173
 
174  
-  cmake -Dbuild_gtest_samples=ON ${GTEST_DIR}
  174
+  cmake -Dgtest_build_samples=ON ${GTEST_DIR}
175 175
 
176 176
 If you are on a *nix system, you should now see a Makefile in the
177 177
 current directory.  Just type 'make' to build gtest.
@@ -262,7 +262,7 @@ and all features using tuple will be disabled.
262 262
 ### Multi-threaded Tests ###
263 263
 
264 264
 Google Test is thread-safe where the pthread library is available.
265  
-After #include <gtest/gtest.h>, you can check the GTEST_IS_THREADSAFE
  265
+After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
266 266
 macro to see whether this is the case (yes if the macro is #defined to
267 267
 1, no if it's undefined.).
268 268
 
@@ -288,7 +288,7 @@ Google Test is compact, so most users can build and link it as a
288 288
 static library for the simplicity.  You can choose to use Google Test
289 289
 as a shared library (known as a DLL on Windows) if you prefer.
290 290
 
291  
-To compile gtest as a shared library, add
  291
+To compile *gtest* as a shared library, add
292 292
 
293 293
   -DGTEST_CREATE_SHARED_LIBRARY=1
294 294
 
@@ -296,12 +296,20 @@ to the compiler flags.  You'll also need to tell the linker to produce
296 296
 a shared library instead - consult your linker's manual for how to do
297 297
 it.
298 298
 
299  
-To compile your tests that use the gtest shared library, add
  299
+To compile your *tests* that use the gtest shared library, add
300 300
 
301 301
   -DGTEST_LINKED_AS_SHARED_LIBRARY=1
302 302
 
303 303
 to the compiler flags.
304 304
 
  305
+Note: while the above steps aren't technically necessary today when
  306
+using some compilers (e.g. GCC), they may become necessary in the
  307
+future, if we decide to improve the speed of loading the library (see
  308
+http://gcc.gnu.org/wiki/Visibility for details).  Therefore you are
  309
+recommended to always add the above flags when using Google Test as a
  310
+shared library.  Otherwise a future release of Google Test may break
  311
+your build script.
  312
+
305 313
 ### Avoiding Macro Name Clashes ###
306 314
 
307 315
 In C++, macros don't obey namespaces.  Therefore two libraries that
@@ -371,7 +379,7 @@ For that you can use CMake:
371 379
 
372 380
   mkdir mybuild
373 381
   cd mybuild
374  
-  cmake -Dbuild_all_gtest_tests=ON ${GTEST_DIR}
  382
+  cmake -Dgtest_build_tests=ON ${GTEST_DIR}
375 383
 
376 384
 Make sure you have Python installed, as some of Google Test's tests
377 385
 are written in Python.  If the cmake command complains about not being
@@ -379,8 +387,7 @@ able to find Python ("Could NOT find PythonInterp (missing:
379 387
 PYTHON_EXECUTABLE)"), try telling it explicitly where your Python
380 388
 executable can be found:
381 389
 
382  
-  cmake -DPYTHON_EXECUTABLE=path/to/python -Dbuild_all_gtest_tests=ON \
383  
-      ${GTEST_DIR}
  390
+  cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
384 391
 
385 392
 Next, you can build Google Test and all of its own tests.  On *nix,
386 393
 this is usually done by 'make'.  To run the tests, do
3,007  thirdparty/gtest/include/gtest/gtest.h → thirdparty/gtest/include/gtest/gtest_ASP.h
2265 additions, 742 deletions not shown
2,061  thirdparty/gtest/src/gtest-all.cc
1331 additions, 730 deletions not shown
11  thirdparty/gtest/src/gtest_main.cc
... ...
@@ -1,10 +1,3 @@
1  
-// __BEGIN_LICENSE__
2  
-// Copyright (C) 2006-2011 United States Government as represented by
3  
-// the Administrator of the National Aeronautics and Space Administration.
4  
-// All Rights Reserved.
5  
-// __END_LICENSE__
6  
-
7  
-
8 1
 // Copyright 2006, Google Inc.
9 2
 // All rights reserved.
10 3
 //
@@ -36,9 +29,9 @@
36 29
 
37 30
 #include <iostream>
38 31
 
39  
-#include <gtest/gtest.h>
  32
+#include "gtest/gtest_ASP.h"
40 33
 
41  
-int main(int argc, char **argv) {
  34
+GTEST_API_ int main(int argc, char **argv) {
42 35
   std::cout << "Running main() from gtest_main.cc\n";
43 36
 
44 37
   testing::InitGoogleTest(&argc, argv);

0 notes on commit 95efdaf

Please sign in to comment.
Something went wrong with that request. Please try again.