[Avida-cvs] [avida-svn] r713 - development/source/tools
kaben@myxo.css.msu.edu
kaben at myxo.css.msu.edu
Sat May 27 03:24:15 PDT 2006
Author: kaben
Date: 2006-05-27 06:24:15 -0400 (Sat, 27 May 2006)
New Revision: 713
Modified:
development/source/tools/cSchedule.cc
development/source/tools/cSchedule.h
Log:
Added memory tracking via tMemTrack. Added unit tests; note that they're
not actually being run yet.
Modified: development/source/tools/cSchedule.cc
===================================================================
--- development/source/tools/cSchedule.cc 2006-05-27 10:23:01 UTC (rev 712)
+++ development/source/tools/cSchedule.cc 2006-05-27 10:24:15 UTC (rev 713)
@@ -31,3 +31,81 @@
item_count = _item_count;
if (m_change_list) m_change_list->Resize(_item_count);
}
+
+
+#ifdef ENABLE_UNIT_TESTS
+
+/*
+Unit tests
+*/
+#include "cFile.h"
+#include "cXMLArchive.h"
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include <cstdio> // for std::remove() to remove temporary files.
+#include <iomanip>
+#include <iostream>
+#include <fstream>
+#include <string>
+
+namespace nSchedule {
+ /*
+ Test-helpers.
+ */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cSchedule_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cSchedule_Archive", s);
+ }
+ class testSchedule : public cSchedule {
+#if USE_tMemTrack
+ tMemTrack<testSchedule> mt;
+#endif
+ public:
+ virtual int GetNextID(){ return 0; }
+ };
+
+ namespace utSchedule_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+ }
+
+ namespace utSchedule_archiving {
+ void test(){
+ std::string filename("./cSchedule_basic_serialization.xml");
+ BOOST_TEST(tMemTrack<cChangeList>::Instances() == 0);
+ {
+ }
+ {
+ }
+
+ std::remove(filename.c_str());
+ }
+ } // utSchedule_archiving
+
+
+ void UnitTests(bool full)
+ {
+ //if(full) {
+ // std::cout << "utSchedule_hello_world" << std::endl;
+ // utSchedule_hello_world::test();
+ //}
+ if(full) {
+ std::cout << "utSchedule_archiving" << std::endl;
+ utSchedule_archiving::test();
+ }
+ }
+} // nSchedule
+
+#endif // ENABLE_UNIT_TESTS
Modified: development/source/tools/cSchedule.h
===================================================================
--- development/source/tools/cSchedule.h 2006-05-27 10:23:01 UTC (rev 712)
+++ development/source/tools/cSchedule.h 2006-05-27 10:24:15 UTC (rev 713)
@@ -11,6 +11,13 @@
#ifndef cSchedule_h
#define cSchedule_h
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
/**
* This class is the base object to handle time-slicing. All other schedulers
* are derived from this class. This is a pure virtual class.
@@ -22,6 +29,9 @@
class cSchedule
{
+#if USE_tMemTrack
+ tMemTrack<cSchedule> mt;
+#endif
protected:
int item_count;
cChangeList* m_change_list;
More information about the Avida-cvs
mailing list