00001 #ifndef TEST_TOOLS_H
00002 #define TEST_TOOLS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <limits.h>
00023
00024 #include <boost/test/test_tools.hpp>
00025 #include <boost/assign/list_of.hpp>
00026 #include <boost/regex.hpp>
00027 #include <boost/assign/list_of.hpp>
00028 #include <vector>
00029 #include <ostream>
00030
00031
00032 template <class T> std::ostream& seqPrint(std::ostream& o, const T& seq) {
00033 std::copy(seq.begin(), seq.end(), std::ostream_iterator<typename T::value_type>(o, " "));
00034 return o;
00035 }
00036
00037
00038 template <class T, class U>
00039 bool seqEqual(const T& a, const U& b) {
00040 typename T::const_iterator i = a.begin();
00041 typename U::const_iterator j = b.begin();
00042 while (i != a.end() && j != b.end() && *i == *j) { ++i; ++j; }
00043 return (i == a.end()) && (j == b.end());
00044 }
00045
00046
00047
00048 namespace std {
00049
00050 template <class T>
00051 ostream& operator<<(ostream& o, const vector<T>& v) { return seqPrint(o, v); }
00052
00053 template <class T>
00054 ostream& operator<<(ostream& o, const boost::assign_detail::generic_list<T>& l) { return seqPrint(o, l); }
00055
00056 template <class T>
00057 bool operator == (const vector<T>& a, const boost::assign_detail::generic_list<T>& b) { return seqEqual(a, b); }
00058
00059 template <class T>
00060 bool operator == (const boost::assign_detail::generic_list<T>& b, const vector<T>& a) { return seqEqual(a, b); }
00061 }
00062
00066 inline bool regexPredicate(const std::string& re, const std::string& text) {
00067 return boost::regex_match(text, boost::regex(re));
00068 }
00069
00071 #if (BOOST_VERSION < 103300)
00072 #define BOOST_CHECK_REGEX(re, text)
00073 #else
00074 #define BOOST_CHECK_REGEX(re, text) \
00075 BOOST_CHECK_PREDICATE(regexPredicate, (re)(text))
00076 #endif
00077
00079 #define BOOST_CHECK_TYPEID_EQUAL(a,b) BOOST_CHECK_EQUAL(typeid(a).name(),typeid(b).name())
00080
00081 #endif