unittest.cpp

Go to the documentation of this file.
00001 
00027 #include <stdio.h>
00028 
00029 #include "unittest.h"
00030 
00031 
00032 void 
00033 UnitTest::print_header(void * stream, const char * tag) {
00034 
00035   char header[] = {"\n\n=================  %s  =================\n"};
00036 
00037   fprintf((FILE*)stream,header,tag);
00038 
00039 }
00040 
00041 
00042 void
00043 UnitTest::register_test_functions(TestFunc * testfunc) {
00044 
00045   this->testfunc = testfunc;
00046 }
00047 
00048 
00054 bool
00055 UnitTest::test() {
00056 
00057     int i = 0;
00058     bool passed = true;
00059 
00060     if (testfunc == NULL) {
00061       return false;
00062     }
00063 
00064     while (testfunc[i].test != NULL) {
00065 
00066         print_header(stdout,testfunc[i].testname);
00067 
00068         if (testfunc[i].test()) {
00069             fprintf(stdout, "Passed test_%s.\n", testfunc[i].testname);
00070         } else {
00071             fprintf(stdout, "Failed test_%s.\n", testfunc[i].testname);
00072             passed = false;
00073         }
00074         i++;
00075     }
00076 
00077     return passed;
00078 }
00079 
00080 

Generated on Mon Oct 23 15:05:31 2006 for OpenSees by doxygen 1.5.0