Go to the documentation of this file.00001
00002 #ifndef mbl_test_h_
00003 #define mbl_test_h_
00004
00005
00006
00007
00008
00009
00010 #include <vcl_sstream.h>
00011 #include <vcl_string.h>
00012 #include <vcl_iostream.h>
00013 #include <vcl_vector.h>
00014 #include <vul/vul_reg_exp.h>
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 template <class S>
00036 bool mbl_test_summaries_are_equal(const S &a, const S &b, const char **exceptions=0 )
00037 {
00038 vcl_stringstream ssa, ssb;
00039 vcl_string sa, sb;
00040 vsl_print_summary(ssa, a);
00041 vsl_print_summary(ssb, b);
00042 vcl_vector<vul_reg_exp> exceptions_re;
00043 while (exceptions && *exceptions)
00044 {
00045 exceptions_re.push_back(vul_reg_exp(*exceptions));
00046 exceptions++;
00047 }
00048
00049 while (!ssa.eof() || !ssb.eof())
00050 {
00051 vcl_getline(ssa, sa);
00052 vcl_getline(ssb, sb);
00053 if (sa != sb && exceptions_re.empty())
00054 {
00055 vcl_cerr << "Found differences:\n>"<<sa<<"\n<"<<sb<<vcl_endl;
00056 return false;
00057 }
00058 else if (sa != sb)
00059 {
00060 bool exception_found = false;
00061
00062
00063 for (vcl_vector<vul_reg_exp>::iterator it=exceptions_re.begin(), end=exceptions_re.end();
00064 it != end; ++it)
00065 if (it->find(sa) && it->find(sb))
00066 {
00067 exception_found = true;
00068 break;
00069 }
00070 if (!exception_found)
00071 {
00072 vcl_cerr << "Found differences:\n>"<<sa<<"\n<"<<sb<<vcl_endl;
00073 return false;
00074 }
00075 }
00076 }
00077 return true;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 void mbl_test_save_measurement( const vcl_string &measurement_path, double value);
00093
00094
00095 #endif // mbl_test_h_