00001
00030 #ifndef __GEO_UNITTEST_H__
00031 #define __GEO_UNITTEST_H__
00032
00033
00038 typedef struct _testfunc {
00039
00040 bool (*test)(void);
00041 const char * testname;
00042 } TestFunc;
00043
00044
00045
00046 class UnitTest {
00047
00048 public:
00049
00050 void register_test_functions (TestFunc * testfunc);
00051
00061 bool test ();
00062
00063 void print_header (void * stream,
00064 const char * tag);
00065
00066 private:
00067
00068 TestFunc * testfunc;
00069
00070 };
00071
00072
00073
00074
00080 template <class T>
00081 bool valarray_equals(std::valarray<T> & v1, std::valarray<T> & v2) {
00082
00083 if (v1.size() != v2.size()) {
00084 std::cout << "Error: mismatched valarray sizes.\n";
00085 return false;
00086 }
00087
00088 for (unsigned int i=0; i<v1.size(); i++) {
00089 if (v1[i] != v2[i]) {
00090 return false;
00091 }
00092 }
00093
00094 return true;
00095 }
00096
00097 template <class T>
00098 void valarray_print(std::valarray<T> & v, const char * label) {
00099
00100 for (unsigned int i=0; i<v.size(); i++) {
00101 std::cout << label << "[" << i << "]: " << v[i] << "\n";
00102 }
00103 }
00104
00123 bool double_array_equals (const double * a,
00124 const double * b,
00125 const int size,
00126 const double tol);
00127
00128
00135 #endif