Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

UnitTest.cpp

00001 #define TRACE_NAME "UnitTest"
00002 
00003 #include "UnitTest.h"
00004 
00005 extern "C" {
00006 #include <string.h>
00007 #include <stdio.h>
00008 }
00009 
00011 //
00012 //  Standard Member Functions
00013 //
00015 
00016 UnitTest *UnitTest::first_instance = 0;
00017 
00018 UnitTest::UnitTest(function f, char *p_file, int p_num, char *p_other_name):
00019     function_pointer(f),
00020     file(p_file),
00021     num(p_num),
00022     other_name(p_other_name)
00023 {
00024     next_instance = first_instance;
00025     first_instance = this;
00026 
00027     name=new char [strlen(file) + strlen(other_name) + 30];
00028     sprintf(name, "%s(#%d) %s", file, num, other_name);
00029 
00030     /*
00031     std::cerr << "Registered a unit tester: " << name << std::endl;
00032     if (next_instance) {
00033     std::cerr << "(linked before: " << next_instance->name << ")" << std::endl;
00034     }
00035     */
00036 }
00037 
00038 #if 0  /* omit definitions until they are implemented */
00039 
00040 UnitTest::UnitTest(const UnitTest& other)
00041 {
00042     NOT_IMPLEMENTED
00043 }
00044 
00045 const UnitTest& UnitTest::operator=(const UnitTest& other)
00046 {
00047     NOT_IMPLEMENTED
00048 }
00049 
00050 bool UnitTest::operator==(const UnitTest& other) const
00051 {
00052     NOT_IMPLEMENTED
00053 }
00054 
00055 bool UnitTest::operator<(const UnitTest& other) const
00056 {
00057     NOT_IMPLEMENTED
00058 }
00059 
00060 size_t UnitTest::hash() const
00061 {
00062     NOT_IMPLEMENTED
00063 }
00064 
00065 std::ostream& UnitTest::print_to(std::ostream& stream) const
00066 {
00067     NOT_IMPLEMENTED
00068 }
00069 
00070 #endif /* omit definitions until they are implemented */
00071     
00072 UnitTest::~UnitTest()
00073 {
00074     delete[] name;
00075 }
00076 
00078 //
00079 //  Additional Public Member Functions
00080 //
00082 
00083 void UnitTest::run_tests(std::ostream& out, char *keyword)
00084 {
00085     for (UnitTest *t = first_instance; t; t=t->next_instance) {
00086     out << "Unit Test " << t->name << ": " ;
00087     if (strstr(t->name, keyword)) {
00088         if ((t->function_pointer)(out)) {
00089         out << "   PASSED" << std::endl;
00090         } else {
00091         out << " **FAILED**" << std::endl;
00092         }
00093     } else {
00094         out << "  skipped" << std::endl;
00095     }
00096     }
00097 }
00098 
00099 void UnitTest::print_name(std::ostream& out)
00100 {
00101     
00102 }
00103 
00104 
00105 
00107 //
00108 //  Additional Private Member Functions
00109 //
00111 
00112 
00113 
00114 #undef TRACE_NAME

Home to blindfold. This page generated via doxygen 1.2.11.1 Wed Oct 10 16:40:33 2001.