core/test_framework.h

00001 #ifndef _TESTFRAMEWORK_H
00002 #define _TESTFRAMEWORK_H
00003 
00004 #ifndef _NO_CPPUNIT
00005 
00006 #include <cppunit/ui/text/TestRunner.h>
00007 #include <cppunit/TestResult.h>
00008 #include <cppunit/TestResultCollector.h>
00009 #include <cppunit/extensions/HelperMacros.h>
00010 #include <cppunit/BriefTestProgressListener.h>
00011 #include <cppunit/extensions/TestFactoryRegistry.h>
00012 #include <cppunit/TextOutputter.h>
00013 #include "gridlabd.h"
00014 #include "test_callbacks.h"
00015 
00016 TEST_CALLBACKS *local_callbacks;
00017 
00018 class test_helper: public CppUnit::TestFixture
00019 {
00020 public:
00021     
00022     static CLASS* get_class_by_name(char *name){
00023         return local_callbacks->get_class_by_name(name);
00024     }
00025 
00026     static TIMESTAMP get_global_clock(){
00027         return local_callbacks->get_global_clock();
00028     }
00029 
00030     static TIMESTAMP myobject_sync(OBJECT *obj, TIMESTAMP ts,PASSCONFIG pass)
00031     {
00032         return local_callbacks->myobject_sync(obj,ts,pass);
00033     }
00034 
00035     template <class T> static T *create_object(const char *classname)
00036     {
00037         CLASS *glclass = get_class_by_name((char *) classname);
00038         OBJECT *gl_obj = gl_create_object(glclass, sizeof(T));
00039         T *obj = OBJECTDATA(gl_obj, T);
00040         obj->create();
00041         return obj;
00042     }
00043 };
00044 #endif
00045 #endif

GridLAB-DTM Version 1.0
An open-source project initiated by the US Department of Energy