[Avida-cvs] [avida-svn] r630 - in development: . consistencytests/Tests/SMT source source/actions source/analyze source/archive source/classification source/cpu source/drivers source/event source/main source/script source/targets/avida source/targets/avida-viewer source/testsuites source/third-party source/third-party/boost/serialization source/third-party/trio source/tools source/utils/task_events support/utils/AvidaUtils
kaben@myxo.css.msu.edu
kaben at myxo.css.msu.edu
Mon May 1 11:17:23 PDT 2006
Author: kaben
Date: 2006-05-01 14:17:22 -0400 (Mon, 01 May 2006)
New Revision: 630
Added:
development/source/actions/SConscript
development/source/archive/
development/source/archive/CMakeLists.txt
development/source/archive/SConscript
development/source/archive/cXMLArchive.cc
development/source/archive/cXMLArchive.h
development/source/testsuites/SConscript
development/source/testsuites/full-unit-tests.cc
development/source/third-party/boost/serialization/CMakeLists.txt
development/source/third-party/trio/SConscript
development/source/tools/cDataEntry.cc
development/source/tools/cTemplateTests.cc
development/source/tools/cTemplateTests.h
development/support/utils/AvidaUtils/BoostPythonTool.py
Modified:
development/CMakeLists.txt
development/SConstruct
development/consistencytests/Tests/SMT/CMakeLists.txt
development/source/CMakeLists.txt
development/source/SConscript
development/source/actions/cAction.h
development/source/actions/cActionLibrary.h
development/source/analyze/cAnalyzeCommand.h
development/source/analyze/cAnalyzeCommandAction.h
development/source/analyze/cAnalyzeCommandDef.h
development/source/analyze/cAnalyzeCommandDefBase.h
development/source/analyze/cAnalyzeFlowCommand.h
development/source/analyze/cAnalyzeFlowCommandDef.h
development/source/analyze/cAnalyzeFunction.h
development/source/analyze/cAnalyzeGenotype.h
development/source/analyze/cAnalyzeJob.h
development/source/analyze/cAnalyzeJobQueue.h
development/source/analyze/cAnalyzeJobWorker.h
development/source/analyze/cAnalyzeUtil.h
development/source/analyze/cGenotypeBatch.h
development/source/classification/cClassificationManager.h
development/source/classification/cGenotype.h
development/source/classification/cGenotypeControl.h
development/source/classification/cGenotype_BirthData.h
development/source/classification/cGenotype_TestData.h
development/source/classification/cInjectGenotype.h
development/source/classification/cInjectGenotypeControl.h
development/source/classification/cInjectGenotypeElement.h
development/source/classification/cInjectGenotypeQueue.h
development/source/classification/cInjectGenotype_BirthData.h
development/source/classification/cLineage.h
development/source/classification/cSpecies.h
development/source/classification/cSpeciesControl.h
development/source/classification/cSpeciesQueue.h
development/source/cpu/SConscript
development/source/cpu/cCPUMemory.h
development/source/cpu/cCPUStack.h
development/source/cpu/cCPUTestInfo.h
development/source/cpu/cCodeLabel.h
development/source/cpu/cHardware4Stack.h
development/source/cpu/cHardware4Stack_Thread.h
development/source/cpu/cHardwareBase.h
development/source/cpu/cHardwareCPU.h
development/source/cpu/cHardwareCPU_Thread.h
development/source/cpu/cHardwareManager.h
development/source/cpu/cHardwareSMT.h
development/source/cpu/cHardwareStatusPrinter.h
development/source/cpu/cHardwareTracer.h
development/source/cpu/cHardwareTracer_4Stack.h
development/source/cpu/cHardwareTracer_CPU.h
development/source/cpu/cHardwareTracer_SMT.h
development/source/cpu/cHardwareTracer_TestCPU.h
development/source/cpu/cHeadCPU.h
development/source/cpu/cHeadMultiMem.h
development/source/cpu/cInstLibCPU.h
development/source/cpu/cTestCPU.h
development/source/cpu/cTestCPUInterface.h
development/source/cpu/cTestUtil.h
development/source/cpu/sCPUStats.h
development/source/drivers/cAvidaDriver.h
development/source/drivers/cDefaultAnalyzeDriver.h
development/source/drivers/cDefaultRunDriver.h
development/source/drivers/cDriverManager.h
development/source/drivers/cFallbackWorldDriver.h
development/source/drivers/cWorldDriver.h
development/source/event/cEvent.h
development/source/event/cEventList.h
development/source/event/cEventListEntry.h
development/source/event/cEventListIterator.h
development/source/event/cEventManager.h
development/source/event/cEventTriggers.h
development/source/main/MyCodeArrayLessThan.h
development/source/main/cAvidaConfig.h
development/source/main/cAvidaTriggers.h
development/source/main/cBirthChamber.h
development/source/main/cEnvironment.h
development/source/main/cFitnessMatrix.h
development/source/main/cGenome.h
development/source/main/cGenomeUtil.h
development/source/main/cInstLibBase.h
development/source/main/cInstSet.h
development/source/main/cInstUtil.h
development/source/main/cInstruction.h
development/source/main/cLandscape.h
development/source/main/cLocalMutations.h
development/source/main/cMutation.h
development/source/main/cMutationLib.h
development/source/main/cMutationRates.h
development/source/main/cMxCodeArray.h
development/source/main/cOrgInterface.h
development/source/main/cOrgMessage.h
development/source/main/cOrgSeqMessage.h
development/source/main/cOrgSinkMessage.h
development/source/main/cOrgSourceMessage.h
development/source/main/cOrganism.h
development/source/main/cPhenotype.h
development/source/main/cPopulation.cc
development/source/main/cPopulation.h
development/source/main/cPopulationCell.h
development/source/main/cPopulationInterface.h
development/source/main/cReaction.h
development/source/main/cReactionLib.h
development/source/main/cReactionProcess.h
development/source/main/cReactionRequisite.h
development/source/main/cReactionResult.h
development/source/main/cResource.h
development/source/main/cResourceCount.h
development/source/main/cResourceLib.h
development/source/main/cSpatialCountElem.h
development/source/main/cSpatialResCount.h
development/source/main/cStats.cc
development/source/main/cStats.h
development/source/main/cTaskContext.h
development/source/main/cTaskEntry.h
development/source/main/cTaskLib.h
development/source/main/cWorld.h
development/source/script/cASLibrary.h
development/source/script/cASSymbol.h
development/source/script/cParser.h
development/source/script/cScriptObject.h
development/source/script/cSymbolTable.h
development/source/targets/avida-viewer/cBarScreen.h
development/source/targets/avida-viewer/cBaseTextWindow.h
development/source/targets/avida-viewer/cEnvironmentScreen.h
development/source/targets/avida-viewer/cHistScreen.h
development/source/targets/avida-viewer/cMapScreen.h
development/source/targets/avida-viewer/cMenuWindow.h
development/source/targets/avida-viewer/cOptionsScreen.h
development/source/targets/avida-viewer/cScreen.h
development/source/targets/avida-viewer/cStatsScreen.h
development/source/targets/avida-viewer/cSymbolUtil.h
development/source/targets/avida-viewer/cTextViewerDriver.h
development/source/targets/avida-viewer/cTextWindow.h
development/source/targets/avida-viewer/cView.h
development/source/targets/avida-viewer/cViewInfo.h
development/source/targets/avida-viewer/cZoomScreen.h
development/source/targets/avida/CMakeLists.txt
development/source/targets/avida/SConscript
development/source/testsuites/CMakeLists.txt
development/source/third-party/CMakeLists.txt
development/source/tools/CMakeLists.txt
development/source/tools/SConscript
development/source/tools/cBlockStruct.h
development/source/tools/cConstSchedule.h
development/source/tools/cCountTracker.h
development/source/tools/cCycleCheck.h
development/source/tools/cDataEntry.h
development/source/tools/cDataFile.h
development/source/tools/cDataFileManager.h
development/source/tools/cDataManager_Base.h
development/source/tools/cDefaultMessageDisplay.h
development/source/tools/cDoubleSum.h
development/source/tools/cFile.cc
development/source/tools/cFile.h
development/source/tools/cFixedBlock.h
development/source/tools/cFixedCoords.h
development/source/tools/cGenesis.h
development/source/tools/cHelpAlias.h
development/source/tools/cHelpEntry.h
development/source/tools/cHelpFullEntry.h
development/source/tools/cHelpManager.h
development/source/tools/cHelpType.h
development/source/tools/cHistogram.h
development/source/tools/cID.h
development/source/tools/cIndexedBlockStruct.h
development/source/tools/cInitFile.cc
development/source/tools/cInitFile.h
development/source/tools/cIntSum.h
development/source/tools/cIntegratedSchedule.h
development/source/tools/cIntegratedScheduleNode.h
development/source/tools/cMerit.h
development/source/tools/cMessageClass.h
development/source/tools/cMessageClosure.h
development/source/tools/cMessageDisplay.h
development/source/tools/cMessageType.h
development/source/tools/cProbSchedule.h
development/source/tools/cRandom.cc
development/source/tools/cRandom.h
development/source/tools/cRefBlock.h
development/source/tools/cRunningAverage.h
development/source/tools/cScaledBlock.h
development/source/tools/cSchedule.h
development/source/tools/cString.cc
development/source/tools/cString.h
development/source/tools/cStringIterator.h
development/source/tools/cStringList.cc
development/source/tools/cStringList.h
development/source/tools/cStringUtil.h
development/source/tools/cThread.h
development/source/tools/cTools.h
development/source/tools/cUInt.h
development/source/tools/cVerifierSuiteRecurser.h
development/source/tools/cWeightedIndex.h
development/source/tools/tArray.h
development/source/tools/tBuffer.h
development/source/tools/tDictionary.h
development/source/tools/tHashTable.h
development/source/tools/tList.h
development/source/tools/tManagedPointerArray.h
development/source/tools/tMatrix.h
development/source/tools/tMemTrack.h
development/source/tools/tSmartArray.h
development/source/utils/task_events/CMakeLists.txt
development/support/utils/AvidaUtils/UnitTestTool.py
Log:
* Added unit testing.
- Supported by CMake and SCons.
* Added serialization to a bunch of classes.
* Renamed SMT consistency tests to "SMT".
Modified: development/CMakeLists.txt
===================================================================
--- development/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -15,16 +15,16 @@
# - release (Release)
# - release with debug info (RelWithDebInfo)
SET(CMAKE_CXX_FLAGS_DEBUG
- "-g ${COMPILER_WARNING_FLAGS} -DDEBUG"
+ "-g ${COMPILER_WARNING_FLAGS} -DDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during debug builds.")
SET(CMAKE_CXX_FLAGS_MINSIZEREL
- "-Os -DNDEBUG"
+ "-Os -DNDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during release minsize builds.")
SET(CMAKE_CXX_FLAGS_RELEASE
- "-O3 -ffast-math -DNDEBUG"
+ "-O3 -ffast-math -DNDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during release builds.")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
- "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -DDEBUG"
+ "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -DDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during release builds.")
# Four types of c compilations:
@@ -33,16 +33,16 @@
# - release (Release)
# - release with debug info (RelWithDebInfo)
SET(CMAKE_C_FLAGS_DEBUG
- "-g ${COMPILER_WARNING_FLAGS} -DDEBUG"
+ "-g ${COMPILER_WARNING_FLAGS} -DDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during debug builds.")
SET(CMAKE_C_FLAGS_MINSIZEREL
- "-Os -DNDEBUG"
+ "-Os -DNDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during release minsize builds.")
SET(CMAKE_C_FLAGS_RELEASE
- "-O3 -ffast-math -DNDEBUG"
+ "-O3 -ffast-math -DNDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during release builds.")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO
- "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -DDEBUG"
+ "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -DDEBUG -DUSE_tMemTrack=1"
CACHE STRING "Flags used by the compiler during release builds.")
# By default, show all build commands.
@@ -229,6 +229,8 @@
SET(TOOLS_SRC_DIR ${PROJECT_SOURCE_DIR}/source/tools)
SET(ACTIONS_SRC_DIR ${PROJECT_SOURCE_DIR}/source/actions)
SET(ANALYZE_SRC_DIR ${PROJECT_SOURCE_DIR}/source/analyze)
+SET(ARCHIVE_SRC_DIR ${PROJECT_SOURCE_DIR}/source/archive)
+SET(BOOST_SRC_DIR ${PROJECT_SOURCE_DIR}/source/third-party/boost)
SET(CLASSIFICATION_SRC_DIR ${PROJECT_SOURCE_DIR}/source/classification)
SET(CPU_SRC_DIR ${PROJECT_SOURCE_DIR}/source/cpu)
SET(DRIVERS_SRC_DIR ${PROJECT_SOURCE_DIR}/source/drivers)
@@ -240,6 +242,8 @@
SET(TOOLS_BLD_DIR ${PROJECT_BINARY_DIR}/source/tools)
SET(ACTIONS_BLD_DIR ${PROJECT_BINARY_DIR}/source/actions)
SET(ANALYZE_BLD_DIR ${PROJECT_BINARY_DIR}/source/analyze)
+SET(ARCHIVE_BLD_DIR ${PROJECT_BINARY_DIR}/source/archive)
+SET(BOOST_SERIALIZATION_BLD_DIR ${PROJECT_BINARY_DIR}/source/third-party/boost/serialization)
SET(CLASSSIFICATION_BLD_DIR ${PROJECT_BINARY_DIR}/source/classification)
SET(CPU_BLD_DIR ${PROJECT_BINARY_DIR}/source/cpu)
SET(DRIVERS_BLD_DIR ${PROJECT_BINARY_DIR}/source/drivers)
@@ -252,6 +256,8 @@
${TOOLS_SRC_DIR}
${ACTIONS_SRC_DIR}
${ANALYZE_SRC_DIR}
+ ${ARCHIVE_SRC_DIR}
+ ${BOOST_SRC_DIR}
${CLASSIFICATION_SRC_DIR}
${CPU_SRC_DIR}
${DRIVERS_SRC_DIR}
@@ -267,6 +273,8 @@
${TOOLS_BLD_DIR}
${ACTIONS_BLD_DIR}
${ANALYZE_BLD_DIR}
+ ${ARCHIVE_BLD_DIR}
+ ${BOOST_SERIALIZATION_BLD_DIR}
${CLASSIFICATION_BLD_DIR}
${CPU_BLD_DIR}
${DRIVERS_BLD_DIR}
Modified: development/SConstruct
===================================================================
--- development/SConstruct 2006-04-26 19:14:41 UTC (rev 629)
+++ development/SConstruct 2006-05-01 18:17:22 UTC (rev 630)
@@ -27,11 +27,16 @@
#
AvidaUtils.Configure(ARGUMENTS, environment)
+if environment.subst('$enableTestCode') in ['1', 'yes']:
+ environment.SetDefault(enableSharedPtr = 1)
+ environment.Append(CPPDEFINES = ['USE_tMemTrack=1'])
+
environment.Append(
CPPPATH = [
'#/source',
'#/source/actions',
'#/source/analyze',
+ '#/source/archive',
'#/source/classification',
'#/source/cpu',
'#/source/drivers',
@@ -43,6 +48,7 @@
LIBPATH = [
'#$buildDir/actions',
'#$buildDir/analyze',
+ '#$buildDir/archive',
'#$buildDir/classification',
'#$buildDir/cpu',
'#$buildDir/drivers',
@@ -53,8 +59,9 @@
],
)
-# Tell SCons to read script in 'source' subdirectory.
+# Tell SCons where to find its subscripts.
environment.SConscript('source/SConscript', build_dir = "$buildDir")
+environment.SConscript('support/config/SConscript')
# Vim modeline to tell Vim that this is a Python script.
Modified: development/consistencytests/Tests/SMT/CMakeLists.txt
===================================================================
--- development/consistencytests/Tests/SMT/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/consistencytests/Tests/SMT/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -8,7 +8,7 @@
# i.e., .../build/Tests/Default/.
#
-SET(TestsName "default")
+SET(TestsName "SMT")
#
# Avida configuration
Modified: development/source/CMakeLists.txt
===================================================================
--- development/source/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -1,8 +1,8 @@
-SUBDIRS(actions analyze classification cpu drivers event main targets third-party tools utils/task_events)
+SUBDIRS(actions analyze archive classification cpu drivers event main targets third-party tools utils/task_events)
IF(AVD_PY_BINDINGS)
SUBDIRS(bindings python)
ENDIF(AVD_PY_BINDINGS)
IF(AVD_UNIT_TESTS)
- #SUBDIRS(testsuites)
+ SUBDIRS(testsuites)
ENDIF(AVD_UNIT_TESTS)
Modified: development/source/SConscript
===================================================================
--- development/source/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -4,6 +4,7 @@
environment.SConscript( [
'actions/SConscript',
'analyze/SConscript',
+ 'archive/SConscript',
'classification/SConscript',
'cpu/SConscript',
'drivers/SConscript',
@@ -12,8 +13,11 @@
'targets/SConscript',
'third-party/SConscript',
'tools/SConscript',
- 'support/SConscript',
+ #'support/SConscript',
#'utils/SConscript',
] )
+if environment['enableTestCode'] in ('True', '1', 1):
+ environment.SConscript('testsuites/SConscript')
+
# vim: set ft=python:
Added: development/source/actions/SConscript
===================================================================
--- development/source/actions/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/actions/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,10 @@
+
+Import('environment')
+
+tools_library = environment.Library('actions',
+ [
+ 'LandscapeActions.cc',
+ ],
+)
+
+# vim: set ft=python:
Modified: development/source/actions/cAction.h
===================================================================
--- development/source/actions/cAction.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/actions/cAction.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -36,6 +36,15 @@
virtual const cString GetDescription() = 0;
virtual void Process(cAvidaContext& ctx) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/actions/cActionLibrary.h
===================================================================
--- development/source/actions/cActionLibrary.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/actions/cActionLibrary.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -24,6 +24,15 @@
{
public:
cActionLibrary() { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeCommand.h
===================================================================
--- development/source/analyze/cAnalyzeCommand.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeCommand.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
equality of two references means that they refer to the same object.
*/
bool operator==(const cAnalyzeCommand &in) const { return &in == this; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeCommandAction.h
===================================================================
--- development/source/analyze/cAnalyzeCommandAction.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeCommandAction.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,15 @@
cAvidaContext& ctx = m_world->GetDefaultContext();
action->Process(ctx);
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeCommandDef.h
===================================================================
--- development/source/analyze/cAnalyzeCommandDef.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeCommandDef.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -34,6 +34,15 @@
(void) command; // used in other types of command defininitions.
(analyze->*CommandFunction)(args);
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeCommandDefBase.h
===================================================================
--- development/source/analyze/cAnalyzeCommandDefBase.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeCommandDefBase.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -29,6 +29,15 @@
virtual bool IsFlowCommand() { return false; }
const cString& GetName() const { return name; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeFlowCommand.h
===================================================================
--- development/source/analyze/cAnalyzeFlowCommand.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeFlowCommand.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -33,6 +33,15 @@
}
tList<cAnalyzeCommand> * GetCommandList() { return &command_list; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeFlowCommandDef.h
===================================================================
--- development/source/analyze/cAnalyzeFlowCommandDef.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeFlowCommandDef.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
}
virtual bool IsFlowCommand() { return true; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeFunction.h
===================================================================
--- development/source/analyze/cAnalyzeFunction.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeFunction.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,6 +38,15 @@
const cString & GetName() { return name; }
tList<cAnalyzeCommand> * GetCommandList() { return &command_list; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeGenotype.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -314,6 +314,15 @@
equality of two references means that they refer to the same object.
*/
bool operator==(const cAnalyzeGenotype &in) const { return &in == this; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeJob.h
===================================================================
--- development/source/analyze/cAnalyzeJob.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeJob.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -25,6 +25,15 @@
int GetID() { return m_id; }
virtual void Run(cAvidaContext& ctx) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeJobQueue.h
===================================================================
--- development/source/analyze/cAnalyzeJobQueue.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeJobQueue.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -52,6 +52,15 @@
void Execute();
cRandom* GetRandom(int jobid) { return m_rng_pool[jobid & MT_RANDOM_INDEX_MASK]; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeJobWorker.h
===================================================================
--- development/source/analyze/cAnalyzeJobWorker.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeJobWorker.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -26,6 +26,15 @@
public:
cAnalyzeJobWorker(cAnalyzeJobQueue* queue) : m_queue(queue) { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cAnalyzeUtil.h
===================================================================
--- development/source/analyze/cAnalyzeUtil.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cAnalyzeUtil.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -69,5 +69,14 @@
// this adds support for evan dorn's InstructionHistogramEvent. -- kgn
static void PrintInstructionAbundanceHistogram(cWorld* world, std::ofstream& fp);
// -- kgn
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/analyze/cGenotypeBatch.h
===================================================================
--- development/source/analyze/cGenotypeBatch.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/analyze/cGenotypeBatch.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -43,6 +43,15 @@
void SetLineage(bool _val=true) { is_lineage = _val; }
void SetAligned(bool _val=true) { is_aligned = _val; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Added: development/source/archive/CMakeLists.txt
===================================================================
--- development/source/archive/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/archive/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,7 @@
+SET(libarchive_a_SOURCES
+ cXMLArchive.cc
+)
+
+INCLUDE_DIRECTORIES(${ALL_INC_DIRS})
+
+ADD_LIBRARY(archive ${libarchive_a_SOURCES})
Added: development/source/archive/SConscript
===================================================================
--- development/source/archive/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/archive/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,11 @@
+
+Import('environment')
+
+environment.Library('archive',
+ [
+ 'cXMLArchive.cc',
+ ],
+)
+
+
+# vim: set ft=python:
Added: development/source/archive/cXMLArchive.cc
===================================================================
--- development/source/archive/cXMLArchive.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/archive/cXMLArchive.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,18 @@
+
+#include "cXMLArchive.h"
+
+// explicitly instantiate for this type of xml stream
+#include <boost/archive/impl/basic_xml_iarchive.ipp>
+#include <boost/archive/impl/archive_pointer_iserializer.ipp>
+#include <boost/archive/impl/xml_iarchive_impl.ipp>
+#include <boost/archive/impl/basic_xml_oarchive.ipp>
+#include <boost/archive/impl/archive_pointer_oserializer.ipp>
+#include <boost/archive/impl/xml_oarchive_impl.ipp>
+
+template class boost::archive::basic_xml_iarchive<cXMLIArchive> ;
+template class boost::archive::detail::archive_pointer_iserializer<cXMLIArchive> ;
+template class boost::archive::xml_iarchive_impl<cXMLIArchive> ;
+template class boost::archive::basic_xml_oarchive<cXMLOArchive> ;
+template class boost::archive::detail::archive_pointer_oserializer<cXMLOArchive> ;
+template class boost::archive::xml_oarchive_impl<cXMLOArchive> ;
+
Added: development/source/archive/cXMLArchive.h
===================================================================
--- development/source/archive/cXMLArchive.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/archive/cXMLArchive.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,97 @@
+#ifndef cXMLArchive_h
+#define cXMLArchive_h
+
+#include <boost/archive/xml_iarchive.hpp>
+#include <boost/archive/xml_oarchive.hpp>
+#include <boost/serialization/binary_object.hpp>
+#include <boost/serialization/shared_ptr.hpp>
+
+//#ifndef tPtr_h
+//#include "tPtr.h"
+//#endif
+
+///*
+//This causes the boost serialization library to treat tPtr as
+//boost::shared_ptr.
+//*/
+//namespace boost { namespace serialization {
+//template<class Archive, class T>
+//void serialize(Archive & a, tPtr<T> &t, const unsigned int version)
+//{ boost::serialization::split_free(a, t, version); }
+//} // namespace serialization
+//} // namespace boost
+
+
+class cXMLIArchive : public boost::archive::xml_iarchive_impl<cXMLIArchive> {
+public:
+ cXMLIArchive(std::istream & is, unsigned int flags = 0)
+ : boost::archive::xml_iarchive_impl<cXMLIArchive>(is, flags)
+ {}
+ ~cXMLIArchive(){};
+
+ template<class T>
+ cXMLIArchive & ArkvObj(const char * name, T & t){
+ return *(this->This()) >> boost::serialization::make_nvp(name, t);
+ }
+ cXMLIArchive & ArkvBinary(const char * name, void * t, std::size_t size){
+ return *(this->This()) >> boost::serialization::make_nvp(
+ name, boost::serialization::make_binary_object(t, size)
+ );
+ }
+ template<class Base, class Derived>
+ cXMLIArchive & ArkvBase(const char * name, Base &, Derived & d){
+ return *(this->This()) >> boost::serialization::make_nvp(
+ name, boost::serialization::base_object<Base >(d)
+ );
+ }
+ template<class Base, class Derived>
+ cXMLIArchive & ArkvBase(const char * name, Derived & d){
+ return *(this->This()) >> boost::serialization::make_nvp(
+ name, boost::serialization::base_object<Base >(d)
+ );
+ }
+
+ template<class T>
+ void SplitLoadSave(T & t, const unsigned int version){
+ boost::serialization::split_member(*this, t, version);
+ }
+};
+
+class cXMLOArchive : public boost::archive::xml_oarchive_impl<cXMLOArchive> {
+public:
+ cXMLOArchive(std::ostream & os, unsigned int flags = 0)
+ : boost::archive::xml_oarchive_impl<cXMLOArchive>(os, flags)
+ {}
+ ~cXMLOArchive(){}
+
+ template<class T>
+ cXMLOArchive & ArkvObj(const char * name, T & t){
+ return *(this->This()) << boost::serialization::make_nvp(name, t);
+ }
+ cXMLOArchive & ArkvBinary(const char * name, void * t, std::size_t size){
+ return *(this->This()) << boost::serialization::make_nvp(
+ name, boost::serialization::make_binary_object(t, size)
+ );
+ }
+ template<class Base, class Derived>
+ cXMLOArchive & ArkvBase(const char * name, Base &, Derived & d){
+ return *(this->This()) << boost::serialization::make_nvp(
+ name, boost::serialization::base_object<Base >(d)
+ );
+ }
+ template<class Base, class Derived>
+ cXMLOArchive & ArkvBase(const char * name, Derived & d){
+ return *(this->This()) << boost::serialization::make_nvp(
+ name, boost::serialization::base_object<Base >(d)
+ );
+ }
+
+ template<class T>
+ void SplitLoadSave(T & t, const unsigned int version){
+ boost::serialization::split_member(*this, t, version);
+ }
+};
+
+
+
+#endif
Modified: development/source/classification/cClassificationManager.h
===================================================================
--- development/source/classification/cClassificationManager.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cClassificationManager.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -184,6 +184,15 @@
bool SaveClone(std::ofstream& fp);
bool LoadClone(std::ifstream & fp);
bool OK();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cGenotype.h
===================================================================
--- development/source/classification/cGenotype.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cGenotype.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -221,6 +221,15 @@
int GetNumOrganisms() { return num_organisms; }
int GetTotalOrganisms() { return total_organisms; }
int GetTotalParasites() { return total_parasites; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline int cGenotype::AddOrganism()
Modified: development/source/classification/cGenotypeControl.h
===================================================================
--- development/source/classification/cGenotypeControl.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cGenotypeControl.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -66,6 +66,15 @@
{ return threads[thread] = historic_list; }
cGenotype * Next(int thread);
cGenotype * Prev(int thread);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cGenotype_BirthData.h
===================================================================
--- development/source/classification/cGenotype_BirthData.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cGenotype_BirthData.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -48,6 +48,15 @@
// population, otherwise:
// [0]=parent1, [1]=parent2, [2]&[3]=grandparents 1, [4]&[5]=grandparents 2
tArray<int> ancestor_ids;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cGenotype_TestData.h
===================================================================
--- development/source/classification/cGenotype_TestData.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cGenotype_TestData.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -25,6 +25,15 @@
int copied_size;
double colony_fitness;
int generations;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cInjectGenotype.h
===================================================================
--- development/source/classification/cInjectGenotype.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cInjectGenotype.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -110,6 +110,15 @@
int RemoveParasite();
int GetNumInjected() { return num_injected; }
int GetTotalInjected() { return total_injected; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/classification/cInjectGenotypeControl.h
===================================================================
--- development/source/classification/cInjectGenotypeControl.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cInjectGenotypeControl.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -64,6 +64,15 @@
{ return threads[thread] = historic_list; }
cInjectGenotype * Next(int thread);
cInjectGenotype * Prev(int thread);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cInjectGenotypeElement.h
===================================================================
--- development/source/classification/cInjectGenotypeElement.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cInjectGenotypeElement.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -36,6 +36,15 @@
void SetNext(cInjectGenotypeElement* in_next) { next = in_next; }
void SetPrev(cInjectGenotypeElement* in_prev) { prev = in_prev; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cInjectGenotypeQueue.h
===================================================================
--- development/source/classification/cInjectGenotypeQueue.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cInjectGenotypeQueue.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -37,6 +37,15 @@
void Insert(cInjectGenotype & in_inject_genotype);
void Remove(cInjectGenotype & in_inject_genotype);
cInjectGenotype * Find(const cGenome & in_genome) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cInjectGenotype_BirthData.h
===================================================================
--- development/source/classification/cInjectGenotype_BirthData.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cInjectGenotype_BirthData.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -37,6 +37,15 @@
cInjectGenotype * parent_genotype; // Pointer to parent genotype...
//cSpecies * parent_species;
int num_offspring_genotypes; // Num offspring genotypes still in memory.
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline cInjectGenotype_BirthData::cInjectGenotype_BirthData(int in_update_born)
Modified: development/source/classification/cLineage.h
===================================================================
--- development/source/classification/cLineage.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cLineage.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -168,6 +168,15 @@
**/
double GetLineageStat2 () const { return m_lineage_stat2; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cSpecies.h
===================================================================
--- development/source/classification/cSpecies.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cSpecies.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -91,6 +91,15 @@
int debug_num_genotypes;
int debug_num_threshold;
#endif
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cSpeciesControl.h
===================================================================
--- development/source/classification/cSpeciesControl.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cSpeciesControl.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -55,6 +55,15 @@
{ return garbage_queue.GetFirst(); }
inline int GetSize() const { return active_queue.GetSize(); }
inline int GetInactiveSize() const { return inactive_queue.GetSize(); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/classification/cSpeciesQueue.h
===================================================================
--- development/source/classification/cSpeciesQueue.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/classification/cSpeciesQueue.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,6 +38,15 @@
inline int GetSize() const { return size; }
inline cSpecies * GetFirst() const { return first; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/SConscript
===================================================================
--- development/source/cpu/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -14,7 +14,6 @@
'cHardwareCPU_Thread.cc',
'cHardwareManager.cc',
'cHardwareSMT.cc',
- 'cHardwareSMT_Thread.cc',
'cHardwareStatusPrinter.cc',
'cHeadCPU.cc',
'cHeadMultiMem.cc',
Modified: development/source/cpu/cCPUMemory.h
===================================================================
--- development/source/cpu/cCPUMemory.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cCPUMemory.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -90,6 +90,15 @@
void Insert(int pos, const cGenome& in_genome);
void Remove(int pos, int num_insts=1);
void Replace(int pos, int num_insts, const cGenome& in_genome);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cCPUStack.h
===================================================================
--- development/source/cpu/cCPUStack.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cCPUStack.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -43,6 +43,15 @@
void SaveState(std::ostream& fp);
void LoadState(std::istream & fp);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/cpu/cCPUTestInfo.h
===================================================================
--- development/source/cpu/cCPUTestInfo.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cCPUTestInfo.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -96,6 +96,15 @@
// And just because these are so commonly used...
double GetGenotypeFitness();
double GetColonyFitness();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cCodeLabel.h
===================================================================
--- development/source/cpu/cCodeLabel.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cCodeLabel.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -69,6 +69,15 @@
int AsIntAdditivePolynomial(const int base) const;
int AsIntFib(const int base) const;
int AsIntPolynomialCoefficent(const int base) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
void cCodeLabel::AddNop(int nop_num) {
Modified: development/source/cpu/cHardware4Stack.h
===================================================================
--- development/source/cpu/cHardware4Stack.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardware4Stack.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -266,6 +266,15 @@
bool Inst_KillThread(cAvidaContext& ctx);
bool Inst_IO(cAvidaContext& ctx);
bool Inst_Inject(cAvidaContext& ctx);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/cpu/cHardware4Stack_Thread.h
===================================================================
--- development/source/cpu/cHardware4Stack_Thread.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardware4Stack_Thread.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -61,6 +61,15 @@
void Reset(cHardwareBase * in_hardware, int _id);
int GetID() const { return id; }
void SetID(int _id) { id = _id; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareBase.h
===================================================================
--- development/source/cpu/cHardwareBase.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareBase.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -143,6 +143,15 @@
protected:
// -------- No-Operation Instruction --------
bool Inst_Nop(cAvidaContext& ctx); // A no-operation instruction that does nothing!
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareCPU.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -424,6 +424,15 @@
//// Placebo ////
bool Inst_Skip(cAvidaContext& ctx);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/cpu/cHardwareCPU_Thread.h
===================================================================
--- development/source/cpu/cHardwareCPU_Thread.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareCPU_Thread.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -60,6 +60,15 @@
void Reset(cHardwareBase* in_hardware, int _id);
int GetID() const { return id; }
void SetID(int _id) { id = _id; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareManager.h
===================================================================
--- development/source/cpu/cHardwareManager.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareManager.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -44,6 +44,15 @@
const cInstSet& GetInstSet() const { return m_inst_set; }
cInstSet& GetInstSet() { return m_inst_set; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareSMT.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -299,6 +299,15 @@
bool Inst_NetLast(cAvidaContext& ctx); // 42
bool Inst_RotateLeft(cAvidaContext& ctx); // 43
bool Inst_RotateRight(cAvidaContext& ctx); // 44
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/cpu/cHardwareStatusPrinter.h
===================================================================
--- development/source/cpu/cHardwareStatusPrinter.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareStatusPrinter.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -63,6 +63,15 @@
virtual void TraceHardware_SMTBonus(cHardwareSMT &hardware);
virtual void TraceHardware_TestCPU(int time_used, int time_allocated, int size,
const cString& final_memory, const cString& child_memory);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareTracer.h
===================================================================
--- development/source/cpu/cHardwareTracer.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareTracer.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -15,6 +15,15 @@
{
public:
virtual ~cHardwareTracer() { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareTracer_4Stack.h
===================================================================
--- development/source/cpu/cHardwareTracer_4Stack.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareTracer_4Stack.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -17,6 +17,15 @@
virtual ~cHardwareTracer_4Stack() { ; }
virtual void TraceHardware_4Stack(cHardware4Stack &) = 0;
virtual void TraceHardware_4StackBonus(cHardware4Stack &) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareTracer_CPU.h
===================================================================
--- development/source/cpu/cHardwareTracer_CPU.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareTracer_CPU.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -18,6 +18,15 @@
virtual ~cHardwareTracer_CPU() { ; }
virtual void TraceHardware_CPU(cHardwareCPU &) = 0;
virtual void TraceHardware_CPUBonus(cHardwareCPU &) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareTracer_SMT.h
===================================================================
--- development/source/cpu/cHardwareTracer_SMT.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareTracer_SMT.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -17,6 +17,15 @@
virtual ~cHardwareTracer_SMT() { ; }
virtual void TraceHardware_SMT(cHardwareSMT &) = 0;
virtual void TraceHardware_SMTBonus(cHardwareSMT &) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHardwareTracer_TestCPU.h
===================================================================
--- development/source/cpu/cHardwareTracer_TestCPU.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHardwareTracer_TestCPU.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -22,6 +22,15 @@
const cString &final_memory,
const cString &child_memory
) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHeadCPU.h
===================================================================
--- development/source/cpu/cHeadCPU.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHeadCPU.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -122,6 +122,15 @@
// Test functions...
int TestParasite() const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cHeadMultiMem.h
===================================================================
--- development/source/cpu/cHeadMultiMem.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cHeadMultiMem.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -61,6 +61,15 @@
bool operator==(const cHeadMultiMem& in_cpu_head) const;
bool AtEnd() const;
bool InMemory() const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cInstLibCPU.h
===================================================================
--- development/source/cpu/cInstLibCPU.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cInstLibCPU.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -79,6 +79,15 @@
}
const cInstruction & GetInstDefault(){ return inst_default; }
const cInstruction & GetInstError(){ return inst_error; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/cpu/cTestCPU.h
===================================================================
--- development/source/cpu/cTestCPU.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cTestCPU.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
public:
cTestResources(cWorld* world);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
class cTestCPU
Modified: development/source/cpu/cTestCPUInterface.h
===================================================================
--- development/source/cpu/cTestCPUInterface.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cTestCPUInterface.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -51,6 +51,15 @@
int ReceiveValue();
bool InjectParasite(cOrganism* parent, const cGenome& injected_code);
bool UpdateMerit(double new_merit);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/cTestUtil.h
===================================================================
--- development/source/cpu/cTestUtil.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/cTestUtil.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
cGenotype * genotype=NULL, int update_out=-1);
static void PrintGenome(cWorld* world, cInjectGenotype * genotype, const cGenome & genome,
cString filename="", int update_out=-1);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/cpu/sCPUStats.h
===================================================================
--- development/source/cpu/sCPUStats.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/cpu/sCPUStats.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -60,6 +60,15 @@
void Clear() { // Called on any New Creature
mut_stats.Clear();
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/drivers/cAvidaDriver.h
===================================================================
--- development/source/drivers/cAvidaDriver.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/drivers/cAvidaDriver.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -25,6 +25,15 @@
virtual ~cAvidaDriver() { ; }
virtual void Run() = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/drivers/cDefaultAnalyzeDriver.h
===================================================================
--- development/source/drivers/cDefaultAnalyzeDriver.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/drivers/cDefaultAnalyzeDriver.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -47,6 +47,15 @@
// Notifications
void NotifyComment(const cString& in_string);
void NotifyWarning(const cString& in_string);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/drivers/cDefaultRunDriver.h
===================================================================
--- development/source/drivers/cDefaultRunDriver.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/drivers/cDefaultRunDriver.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -47,6 +47,15 @@
// Notifications
void NotifyComment(const cString& in_string);
void NotifyWarning(const cString& in_string);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/drivers/cDriverManager.h
===================================================================
--- development/source/drivers/cDriverManager.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/drivers/cDriverManager.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -46,6 +46,15 @@
static void Unregister(cAvidaDriver* drv);
static void Unregister(cWorldDriver* drv);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/drivers/cFallbackWorldDriver.h
===================================================================
--- development/source/drivers/cFallbackWorldDriver.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/drivers/cFallbackWorldDriver.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -37,6 +37,15 @@
// Notifications
void NotifyComment(const cString& in_string);
void NotifyWarning(const cString& in_string);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/drivers/cWorldDriver.h
===================================================================
--- development/source/drivers/cWorldDriver.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/drivers/cWorldDriver.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
// Notifications
virtual void NotifyComment(const cString& in_string) = 0;
virtual void NotifyWarning(const cString& in_string) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/event/cEvent.h
===================================================================
--- development/source/event/cEvent.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/event/cEvent.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -55,6 +55,15 @@
// Name and description of the event
virtual const cString GetName() const = 0;
virtual const cString GetDescription() const = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/event/cEventList.h
===================================================================
--- development/source/event/cEventList.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/event/cEventList.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -135,6 +135,15 @@
// kaben changed this member function to static for easy access by
// cEventListIterator.
static void PrintEvent(cEventListEntry * event, std::ostream& os = std::cout);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/event/cEventListEntry.h
===================================================================
--- development/source/event/cEventListEntry.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/event/cEventListEntry.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -104,6 +104,15 @@
cEventListEntry* GetPrev() const { return m_prev; }
cEventListEntry* GetNext() const { return m_next; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/event/cEventListIterator.h
===================================================================
--- development/source/event/cEventListIterator.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/event/cEventListIterator.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,15 @@
m_node = m_node->GetNext();
return *this;
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/event/cEventManager.h
===================================================================
--- development/source/event/cEventManager.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/event/cEventManager.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
cEvent* ConstructEvent(const cString name, const cString& args);
void PrintAllEventDescriptions();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/event/cEventTriggers.h
===================================================================
--- development/source/event/cEventTriggers.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/event/cEventTriggers.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,6 +38,15 @@
virtual double GetGeneration() const = 0;
double GetTriggerValue( eTriggerVariable trigger ) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/MyCodeArrayLessThan.h
===================================================================
--- development/source/main/MyCodeArrayLessThan.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/MyCodeArrayLessThan.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -19,6 +19,15 @@
{
public:
bool operator()(const cMxCodeArray& x, const cMxCodeArray& y) const { return x < y; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cAvidaConfig.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -272,6 +272,15 @@
void Status();
void GenerateOverides();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
// Concept:
Modified: development/source/main/cAvidaTriggers.h
===================================================================
--- development/source/main/cAvidaTriggers.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cAvidaTriggers.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -37,6 +37,15 @@
double GetUpdate() const { return (double) m_stats.GetUpdate(); }
double GetGeneration() const { return m_stats.SumGeneration().Average(); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cBirthChamber.h
===================================================================
--- development/source/main/cBirthChamber.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cBirthChamber.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -102,6 +102,15 @@
// Check the neighborhood for waiting genomes
bool GetNeighborWaiting(const int & parent_id, int world_x, int world_y);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cEnvironment.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -120,6 +120,15 @@
bool SetReactionValue(const cString & name, double value);
bool SetReactionValueMult(const cString & name, double value_mult);
bool SetReactionInst(const cString & name, cString inst_name);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cFitnessMatrix.h
===================================================================
--- development/source/main/cFitnessMatrix.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cFitnessMatrix.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -151,6 +151,15 @@
**/
void CalcFitnessMatrix( int depth_limit, double fitness_threshold_ratio, int ham_thresh, double error_rate_min, double error_rate_max, double error_rate_step, double vect_fmax, double vect_fstep, int diag_iters, bool write_ham_vector, bool write_full_vector );
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cGenome.h
===================================================================
--- development/source/main/cGenome.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cGenome.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -56,6 +56,15 @@
int GetSize() const { return active_size; }
cString AsString() const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cGenomeUtil.h
===================================================================
--- development/source/main/cGenomeUtil.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cGenomeUtil.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
static cGenome Crop(const cGenome& genome, int start, int end);
static cGenome Cut(const cGenome& genome, int start, int end);
static cGenome Join(const cGenome& genome1, const cGenome& genome2);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cInstLibBase.h
===================================================================
--- development/source/main/cInstLibBase.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cInstLibBase.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -31,6 +31,15 @@
virtual cInstruction GetInst(const cString & in_name) = 0;
virtual const cInstruction & GetInstDefault() = 0;
virtual const cInstruction & GetInstError() = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cInstSet.h
===================================================================
--- development/source/main/cInstSet.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cInstSet.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -168,6 +168,15 @@
return inst_error2;
}
// static const cInstruction & GetInstNone() { return inst_none; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/main/cInstUtil.h
===================================================================
--- development/source/main/cInstUtil.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cInstUtil.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -43,6 +43,15 @@
// ========= Genome Construction =========
static cGenome RandomGenome(cAvidaContext& ctx, int length, const cInstSet & inst_set);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cInstruction.h
===================================================================
--- development/source/main/cInstruction.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cInstruction.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
// Some extra methods to convert too and from alpha-numeric symbols...
char GetSymbol() const;
void SetSymbol(char symbol);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cLandscape.h
===================================================================
--- development/source/main/cLandscape.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cLandscape.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -198,6 +198,15 @@
inline int GetNumTrials() const { return trials; }
inline double GetTotalEntropy() const { return total_entropy; }
inline double GetComplexity() const { return complexity; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cLocalMutations.h
===================================================================
--- development/source/main/cLocalMutations.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cLocalMutations.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,6 +38,15 @@
void IncCount(int id) { counts[id]++; }
void IncCount(int id, int num_mut) { counts[id] += num_mut; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cMutation.h
===================================================================
--- development/source/main/cMutation.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cMutation.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -47,6 +47,15 @@
equality of two references means that they refer to the same object.
*/
bool operator==(const cMutation &in) const { return &in == this; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cMutationLib.h
===================================================================
--- development/source/main/cMutationLib.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cMutationLib.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
const tArray<cMutation*>& GetMutationArray() const { return mutation_array; }
const tList<cMutation>& GetMutationList(int trigger) const { return trigger_list_array[trigger]; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cMutationRates.h
===================================================================
--- development/source/main/cMutationRates.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cMutationRates.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -93,6 +93,15 @@
void SetParentMutProb(double in_prob) { divide.parent_mut_prob = in_prob; }
void SetCrossoverProb(double in_prob) { divide.crossover_prob = in_prob; }
void SetAlignedCrossProb(double in) { divide.aligned_cross_prob = in; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cMxCodeArray.h
===================================================================
--- development/source/main/cMxCodeArray.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cMxCodeArray.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -112,6 +112,15 @@
int HammingDistance(const cMxCodeArray &other_gene) const;
double TransitionProbability(const cMxCodeArray &other_gene, double errorRate) const;
void PrintTransitionList(std::ostream& fp, int size) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
cInstruction & cMxCodeArray::operator[](int index)
Modified: development/source/main/cOrgInterface.h
===================================================================
--- development/source/main/cOrgInterface.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cOrgInterface.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -51,6 +51,15 @@
virtual int ReceiveValue() = 0;
virtual bool InjectParasite(cOrganism* parent, const cGenome& injected_code) = 0;
virtual bool UpdateMerit(double new_merit) = 0;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cOrgMessage.h
===================================================================
--- development/source/main/cOrgMessage.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cOrgMessage.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,6 +38,15 @@
void GetData(std::string & in_data) { in_data=data; }
void GetData(int & in_data);
void GetData(double & in_data);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cOrgSeqMessage.h
===================================================================
--- development/source/main/cOrgSeqMessage.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cOrgSeqMessage.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -24,6 +24,15 @@
void SetReceived() { m_recvd = true; }
bool GetReceived() { return m_recvd; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cOrgSinkMessage.h
===================================================================
--- development/source/main/cOrgSinkMessage.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cOrgSinkMessage.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -29,6 +29,15 @@
void SetValidated() { m_validated = true; }
bool GetValidated() { return m_validated; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cOrgSourceMessage.h
===================================================================
--- development/source/main/cOrgSourceMessage.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cOrgSourceMessage.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -30,6 +30,15 @@
void SetDropped() { m_dropped++; }
int GetCorrupted() { return m_corrupt; }
void SetCorrupted() { m_corrupt++; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cOrganism.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -260,6 +260,15 @@
// Other Special Functions
void Fault(int fault_loc, int fault_type, cString fault_desc="");
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cPhenotype.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -280,6 +280,15 @@
int& CrossNum() { assert(initialized == true); return cross_num; }
bool& ChildFertile() { assert(initialized == true); return child_fertile; }
bool& IsMultiThread() { assert(initialized == true); return is_multi_thread; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cPopulation.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,7 @@
#include <algorithm>
#include <set>
+#include <float.h>
#include <math.h>
using namespace std;
@@ -1104,8 +1105,8 @@
int max_genome_length = 0;
// Minimums...
- cMerit min_merit(HUGE_VAL);
- double min_fitness = HUGE_VAL;
+ cMerit min_merit(FLT_MAX);
+ double min_fitness = FLT_MAX;
int min_gestation_time = INT_MAX;
int min_genome_length = INT_MAX;
Modified: development/source/main/cPopulation.h
===================================================================
--- development/source/main/cPopulation.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cPopulation.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -186,6 +186,15 @@
void SetChangeList(cChangeList* change_list);
cChangeList* GetChangeList();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cPopulationCell.h
===================================================================
--- development/source/main/cPopulationCell.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cPopulationCell.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -70,6 +70,15 @@
bool IsOccupied() const { return organism != NULL; }
bool OK();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cPopulationInterface.h
===================================================================
--- development/source/main/cPopulationInterface.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cPopulationInterface.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -60,6 +60,15 @@
int ReceiveValue();
bool InjectParasite(cOrganism* parent, const cGenome& injected_code);
bool UpdateMerit(double new_merit);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cReaction.h
===================================================================
--- development/source/main/cReaction.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cReaction.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -62,6 +62,15 @@
double GetValue(int process_num = 0);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cReactionLib.h
===================================================================
--- development/source/main/cReactionLib.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cReactionLib.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
cReaction* AddReaction(const cString& name);
cReaction* GetReaction(const cString& name) const;
cReaction* GetReaction(int id) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cReactionProcess.h
===================================================================
--- development/source/main/cReactionProcess.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cReactionProcess.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -98,6 +98,15 @@
void SetDetectionThreshold(double _in) { detection_threshold = _in; }
void SetDetectionError(double _in) { detection_error = _in; }
void SetMatchString(cString _in) { match_string = _in; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cReactionRequisite.h
===================================================================
--- development/source/main/cReactionRequisite.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cReactionRequisite.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -52,6 +52,15 @@
equality of two references means that they refer to the same object.
*/
bool operator==(const cReactionRequisite& in) const { return &in == this; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cReactionResult.h
===================================================================
--- development/source/main/cReactionResult.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cReactionResult.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -67,6 +67,15 @@
double GetAddBonus() { return bonus_add; }
double GetMultBonus() { return bonus_mult; }
tArray<int>& GetInstArray() { return insts_triggered; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cResource.h
===================================================================
--- development/source/main/cResource.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cResource.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -80,6 +80,15 @@
void SetXGravity(double _xgravity) { xgravity = _xgravity; }
void SetYDiffuse(double _ydiffuse) { ydiffuse = _ydiffuse; }
void SetYGravity(double _ygravity) { ygravity = _ygravity; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cResourceCount.h
===================================================================
--- development/source/main/cResourceCount.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cResourceCount.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -79,6 +79,15 @@
}
void ResizeSpatialGrids(int in_x, int in_y);
cSpatialResCount GetSpatialResource(int id) { return spatial_resource_count[id]; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cResourceLib.h
===================================================================
--- development/source/main/cResourceLib.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cResourceLib.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
cResource* AddResource(const cString& res_name);
cResource* GetResource(const cString& res_name) const;
cResource* GetResource(int id) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cSpatialCountElem.h
===================================================================
--- development/source/main/cSpatialCountElem.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cSpatialCountElem.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -36,6 +36,15 @@
double GetPtrDist(int innum) { return dist[innum]; }
friend void FlowMatter(cSpatialCountElem&, cSpatialCountElem&, double, double, double, double,
int, int, double);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cSpatialResCount.h
===================================================================
--- development/source/main/cSpatialResCount.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cSpatialResCount.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -66,6 +66,15 @@
void SetOutflowX2(int in_outflowX2) { outflowX2 = in_outflowX2; }
void SetOutflowY1(int in_outflowY1) { outflowY1 = in_outflowY1; }
void SetOutflowY2(int in_outflowY2) { outflowY2 = in_outflowY2; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cStats.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -16,6 +16,7 @@
#include "tDataEntry.h"
#include "cWorld.h"
+#include <float.h>
#include <math.h>
using namespace std;
@@ -46,8 +47,8 @@
, max_merit(0)
, max_gestation_time(0)
, max_genome_length(0)
- , min_fitness(HUGE_VAL)
- , min_merit(HUGE_VAL)
+ , min_fitness(FLT_MAX)
+ , min_merit(FLT_MAX)
, min_gestation_time(INT_MAX)
, min_genome_length(INT_MAX)
, dom_genotype_id(-1)
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cStats.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -548,6 +548,15 @@
void PrintMutationRateData(const cString& filename);
void PrintInstructionData(const cString& filename);
void PrintGenotypeMap(const cString& filename);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/main/cTaskContext.h
===================================================================
--- development/source/main/cTaskContext.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cTaskContext.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -37,6 +37,15 @@
other_output_buffers(other_outputs), net_valid(in_net_valid), net_completed(in_net_completed), logic_id(0)
{
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cTaskEntry.h
===================================================================
--- development/source/main/cTaskEntry.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cTaskEntry.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -44,6 +44,15 @@
const int GetID() const { return m_id; }
const tTaskTest GetTestFun() const { return m_test_fun; }
const cString & GetInfo() const { return m_info; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/main/cTaskLib.h
===================================================================
--- development/source/main/cTaskLib.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cTaskLib.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -219,6 +219,15 @@
double Task_NetSend(cTaskContext* ctx) const;
double Task_NetReceive(cTaskContext* ctx) const;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/main/cWorld.h
===================================================================
--- development/source/main/cWorld.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/main/cWorld.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -106,6 +106,15 @@
void GetEvents();
void ReadEventListFile(const cString & filename);
void SyncEventList();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/script/cASLibrary.h
===================================================================
--- development/source/script/cASLibrary.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/script/cASLibrary.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -25,6 +25,15 @@
public:
cASLibrary() { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/script/cASSymbol.h
===================================================================
--- development/source/script/cASSymbol.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/script/cASSymbol.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -23,6 +23,15 @@
public:
cASSymbol(cString name) : m_name(name) { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/script/cParser.h
===================================================================
--- development/source/script/cParser.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/script/cParser.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -39,6 +39,15 @@
cParser(cASLibrary* library) : m_library(library), m_symtbl(NULL) { ; }
cScriptObject* Parse(std::istream* input);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/script/cScriptObject.h
===================================================================
--- development/source/script/cScriptObject.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/script/cScriptObject.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -16,6 +16,15 @@
public:
cScriptObject() { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/script/cSymbolTable.h
===================================================================
--- development/source/script/cSymbolTable.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/script/cSymbolTable.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -25,6 +25,15 @@
public:
cSymbolTable() { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida/CMakeLists.txt
===================================================================
--- development/source/targets/avida/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -2,9 +2,9 @@
ADD_EXECUTABLE(avida primitive.cc)
IF(MSVC)
- TARGET_LINK_LIBRARIES(avida main classification cpu event analyze drivers analyze cpu tools actions main)
+ TARGET_LINK_LIBRARIES(avida main classification cpu event analyze drivers analyze cpu tools actions main archive boost_serialization)
ELSE(MSVC)
- TARGET_LINK_LIBRARIES(avida main classification cpu event analyze drivers analyze cpu tools actions pthread main)
+ TARGET_LINK_LIBRARIES(avida main classification cpu event analyze drivers analyze cpu tools actions pthread main archive boost_serialization)
ENDIF(MSVC)
LINK_DIRECTORIES(${ALL_LIB_DIRS})
INSTALL_TARGETS(/work avida)
Modified: development/source/targets/avida/SConscript
===================================================================
--- development/source/targets/avida/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -14,6 +14,8 @@
'tools',
'actions',
'main',
+ 'archive',
+ 'boost_serialization',
],
)
environment.Install('$execPrefix', avida)
Modified: development/source/targets/avida-viewer/cBarScreen.h
===================================================================
--- development/source/targets/avida-viewer/cBarScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cBarScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -28,6 +28,15 @@
void Draw();
void Update();
void DoInput(int in_char) { (void) in_char; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cBaseTextWindow.h
===================================================================
--- development/source/targets/avida-viewer/cBaseTextWindow.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cBaseTextWindow.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
int GetY() { return y; }
void Set(int _x, int _y) { x = _x; y = _y; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/targets/avida-viewer/cEnvironmentScreen.h
===================================================================
--- development/source/targets/avida-viewer/cEnvironmentScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cEnvironmentScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,15 @@
void DrawReaction();
void UpdateResource();
void UpdateReaction();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cHistScreen.h
===================================================================
--- development/source/targets/avida-viewer/cHistScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cHistScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
void Draw();
void Update();
void DoInput(int in_char);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cMapScreen.h
===================================================================
--- development/source/targets/avida-viewer/cMapScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cMapScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
// Virtual in map screen.
void Navigate();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/targets/avida-viewer/cMenuWindow.h
===================================================================
--- development/source/targets/avida-viewer/cMenuWindow.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cMenuWindow.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,15 @@
int Activate();
inline void SetActive(int in_id) { active_id = in_id; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cOptionsScreen.h
===================================================================
--- development/source/targets/avida-viewer/cOptionsScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cOptionsScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -24,6 +24,15 @@
void Draw();
void Update();
void DoInput(int in_char) { (void) in_char; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cScreen.h
===================================================================
--- development/source/targets/avida-viewer/cScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -77,6 +77,15 @@
virtual void DoInput(int in_char) = 0;
virtual void DoMouseClick(int x, int y) { (void) x; (void) y; }
virtual void Exit() { ; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/targets/avida-viewer/cStatsScreen.h
===================================================================
--- development/source/targets/avida-viewer/cStatsScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cStatsScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -32,6 +32,15 @@
void Draw();
void Update();
void DoInput(int in_char);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cSymbolUtil.h
===================================================================
--- development/source/targets/avida-viewer/cSymbolUtil.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cSymbolUtil.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -22,6 +22,15 @@
static char GetMutSymbol( const cPopulationCell & cell );
static char GetThreadSymbol(const cPopulationCell & cell);
static char GetLineageSymbol( const cPopulationCell & cell );
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cTextViewerDriver.h
===================================================================
--- development/source/targets/avida-viewer/cTextViewerDriver.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cTextViewerDriver.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -48,6 +48,15 @@
// Notifications
void NotifyComment(const cString& in_string);
void NotifyWarning(const cString& in_string);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cTextWindow.h
===================================================================
--- development/source/targets/avida-viewer/cTextWindow.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cTextWindow.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -132,6 +132,15 @@
inline void SetBoldColor(int color) {
wattrset(win_id, COLOR_PAIR(color) | A_BOLD);
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cView.h
===================================================================
--- development/source/targets/avida-viewer/cView.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cView.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -87,6 +87,15 @@
// Methods called by sub-windows.
static void Redraw();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/targets/avida-viewer/cViewInfo.h
===================================================================
--- development/source/targets/avida-viewer/cViewInfo.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cViewInfo.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -125,6 +125,15 @@
void SetPauseLevel(int in_level) { pause_level = in_level; }
void SetThreadLock(int in_lock) { thread_lock = in_lock; }
void SetStepOrganism(int in_id) { step_organism_id = in_id; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline void cViewInfo::DecMapMode()
Modified: development/source/targets/avida-viewer/cZoomScreen.h
===================================================================
--- development/source/targets/avida-viewer/cZoomScreen.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/targets/avida-viewer/cZoomScreen.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -128,6 +128,15 @@
// Other misc functions...
void AdvanceUpdate() { memory_offset = 0; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/testsuites/CMakeLists.txt
===================================================================
--- development/source/testsuites/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/testsuites/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -1 +1,14 @@
-SUBDIRS(unit_testsuites)
+#SUBDIRS(unit_testsuites)
+
+INCLUDE_DIRECTORIES(${ALL_INC_DIRS})
+
+ADD_EXECUTABLE(full-unit-tests full-unit-tests.cc)
+IF(MSVC)
+ TARGET_LINK_LIBRARIES(full-unit-tests main classification cpu event analyze drivers analyze cpu tools actions main archive boost_serialization)
+ELSE(MSVC)
+ TARGET_LINK_LIBRARIES(full-unit-tests main classification cpu event analyze drivers analyze cpu tools actions pthread main archive boost_serialization)
+ENDIF(MSVC)
+LINK_DIRECTORIES(${ALL_LIB_DIRS})
+INSTALL_TARGETS(/work full-unit-tests)
+
+ADD_TEST("full-unit-tests" "${EXECUTABLE_OUTPUT_PATH}/full-unit-tests")
Added: development/source/testsuites/SConscript
===================================================================
--- development/source/testsuites/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/testsuites/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,59 @@
+import os.path
+import string
+import tempfile
+
+
+def PhonyTarget(alias, action, depends = None):
+ """Returns an alias to a command that performs the action.
+ Implementated by a Command with a nonexistant file target. This command will
+ run on every build, and will never be considered 'up to date'. Acts like a
+ 'phony' target in make.
+ """
+ phony_file = os.path.normpath(tempfile.mktemp(prefix="phony_%s_" % alias, dir="."))
+ Depends(phony_file, depends)
+ return Alias(alias, Command(target=phony_file, source=None, action=action))
+
+def Test(env, prg):
+ """Creates unit test from given program.
+ When unit test passes, a file stamp is made. If it ran successfully and there
+ is nothing changed, the unit test can be skipped next time.
+
+ Makes three alii: the name of program, force-test, and test-changed:
+ - First can be used to run individual unit test.
+ - Second forces all unit tests to run.
+ - Third is used to run unit tests that changed or whose dependencies changed.
+ """
+ name = str(prg[0])
+ stamp = name + '.passed'
+ env.UnitTest(stamp, prg)
+ alias = PhonyTarget(name, [prg], stamp)
+ env.Alias('force-test', name)
+ env.Alias('test-changed', stamp)
+
+
+
+
+Import('environment')
+
+full_unit_tests = environment.Program('full-unit-tests',
+ 'full-unit-tests.cc',
+ LIBS = [
+ 'main',
+ 'classification',
+ 'cpu',
+ 'event',
+ 'analyze',
+ 'drivers',
+ 'analyze',
+ 'cpu',
+ 'tools',
+ 'actions',
+ 'main',
+ 'archive',
+ 'boost_serialization',
+ ],
+)
+
+Test(environment, full_unit_tests)
+
+# vim: set ft=python:
Added: development/source/testsuites/full-unit-tests.cc
===================================================================
--- development/source/testsuites/full-unit-tests.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/testsuites/full-unit-tests.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,22 @@
+#include "cDataEntry.h"
+#include "cFile.h"
+#include "cInitFile.h"
+#include "cRandom.h"
+#include "cString.h"
+#include "cTemplateTests.h"
+
+#include <boost/detail/lightweight_test.hpp>
+
+int main() {
+
+ cDataEntry::UnitTests(true);
+ cFile::UnitTests(true);
+ cInitFile::UnitTests(true);
+ cRandom::UnitTests(true);
+ cString::UnitTests(true);
+ cStringList::UnitTests(true);
+ cTemplateTests::UnitTests(true);
+
+ return boost::report_errors();
+}
+
Modified: development/source/third-party/CMakeLists.txt
===================================================================
--- development/source/third-party/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/third-party/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -1,9 +1,8 @@
+SUBDIRS(boost/serialization)
+
IF(AVD_GUI_NCURSES)
SUBDIRS(trio)
ENDIF(AVD_GUI_NCURSES)
-IF(AVD_UNIT_TESTS)
- SUBDIRS(yaktest)
-ENDIF(AVD_UNIT_TESTS)
IF(BUILD_AvidaSupportLibs)
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/AvidaSupportLibs/CMakeLists.txt)
Added: development/source/third-party/boost/serialization/CMakeLists.txt
===================================================================
--- development/source/third-party/boost/serialization/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/third-party/boost/serialization/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,32 @@
+SET(libboost_serialization_a_SOURCES
+ basic_archive.cpp
+ basic_archive_impl.cpp
+ basic_iarchive.cpp
+ basic_oarchive.cpp
+ basic_iserializer.cpp
+ basic_oserializer.cpp
+ basic_pointer_iserializer.cpp
+ basic_pointer_oserializer.cpp
+ basic_serializer_map.cpp
+ basic_text_iprimitive.cpp
+ basic_text_oprimitive.cpp
+ basic_xml_archive.cpp
+ binary_iarchive.cpp
+ binary_oarchive.cpp
+ extended_type_info.cpp
+ extended_type_info_no_rtti.cpp
+ extended_type_info_typeid.cpp
+ polymorphic_iarchive.cpp
+ polymorphic_oarchive.cpp
+ stl_port.cpp
+ text_iarchive.cpp
+ text_oarchive.cpp
+ void_cast.cpp
+ xml_grammar.cpp
+ xml_iarchive.cpp
+ xml_oarchive.cpp
+)
+
+INCLUDE_DIRECTORIES(${ALL_INC_DIRS})
+
+ADD_LIBRARY(boost_serialization ${libboost_serialization_a_SOURCES})
Added: development/source/third-party/trio/SConscript
===================================================================
--- development/source/third-party/trio/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/third-party/trio/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,13 @@
+
+Import('environment')
+
+environment.Library('trio',
+ [
+ 'trio.c',
+ 'triostr.c',
+ 'trionan.c',
+ ],
+)
+
+
+# vim: set ft=python:
Modified: development/source/tools/CMakeLists.txt
===================================================================
--- development/source/tools/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -2,6 +2,7 @@
cBlockStruct.cc
cChangeList.cc
cConstSchedule.cc
+ cDataEntry.cc
cDataFile.cc
cDataFileManager.cc
cDataManager_Base.cc
@@ -27,6 +28,7 @@
cStringIterator.cc
cStringList.cc
cStringUtil.cc
+ cTemplateTests.cc
cThread.cc
cTools.cc
cWeightedIndex.cc
Modified: development/source/tools/SConscript
===================================================================
--- development/source/tools/SConscript 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/SConscript 2006-05-01 18:17:22 UTC (rev 630)
@@ -6,6 +6,7 @@
'cBlockStruct.cc',
'cChangeList.cc',
'cConstSchedule.cc',
+ 'cDataEntry.cc',
'cDataFile.cc',
'cDataFileManager.cc',
'cDataManager_Base.cc',
@@ -31,6 +32,7 @@
'cStringIterator.cc',
'cStringList.cc',
'cStringUtil.cc',
+ 'cTemplateTests.cc',
'cThread.cc',
'cTools.cc',
'cWeightedIndex.cc',
Modified: development/source/tools/cBlockStruct.h
===================================================================
--- development/source/tools/cBlockStruct.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cBlockStruct.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -228,6 +228,15 @@
inline int GetFixedSize() const { return fixed_size; }
inline int GetBlocksUsed() const { return fixed_used.GetBlockNum() + 1; }
inline void SetFixedSize(int in_fs) { fixed_size = in_fs; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline void * cBlockStruct::Find(const cFixedCoords & search_coords) const
Modified: development/source/tools/cConstSchedule.h
===================================================================
--- development/source/tools/cConstSchedule.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cConstSchedule.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -44,6 +44,15 @@
void Adjust(int item_id, const cMerit& merit);
int GetNextID();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cCountTracker.h
===================================================================
--- development/source/tools/cCountTracker.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cCountTracker.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -30,6 +30,15 @@
void Dec() { cur_count--; }
void Next() { last_count = cur_count; cur_count = 0; }
void Clear() { cur_count = last_count = total_count = 0; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cCycleCheck.h
===================================================================
--- development/source/tools/cCycleCheck.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cCycleCheck.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -64,6 +64,15 @@
verification.
*/
~cCycleCheck();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Added: development/source/tools/cDataEntry.cc
===================================================================
--- development/source/tools/cDataEntry.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDataEntry.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,97 @@
+/*
+ * cDataEntry.cc
+ * Avida
+ *
+ * Copyright 2005-2006 Michigan State University. All rights reserved.
+ * Copyright 1993-2003 California Institute of Technology
+ *
+ */
+
+#include "cDataEntry.h"
+
+/*
+Unit tests
+*/
+#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 nDataEntryTests {
+ /*
+ Test-helpers.
+ */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cDataEntry_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cDataEntry_Archive", s);
+ }
+
+
+ namespace utDataEntry_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+ }
+
+ namespace utDataEntry_archiving {
+ void test(){
+ std::string filename("./cDataEntry_basic_serialization.xml");
+
+ // Open cDataEntry_data.txt for reading.
+ cDataEntry d("name", "desc", "null_value", "html_table_flags");
+ cDataEntry d1("n", "d", "nv", "htf");
+
+ // Sanity checks...
+ BOOST_TEST(cString("name") == d.GetName());
+ BOOST_TEST(cString("desc") == d.GetDesc());
+ BOOST_TEST(cString("null_value") == d.GetNull());
+ BOOST_TEST(cString("html_table_flags") == d.GetHtmlCellFlags());
+
+ BOOST_TEST(cString("n") == d1.GetName());
+ BOOST_TEST(cString("d") == d1.GetDesc());
+ BOOST_TEST(cString("nv") == d1.GetNull());
+ BOOST_TEST(cString("htf") == d1.GetHtmlCellFlags());
+
+ // Save cDataEntry state.
+ save_stuff<>(d, filename.c_str());
+ // Reload state into new cDataEntry.
+ restore_stuff<>(d1, filename.c_str());
+
+ // Check reloaded state.
+ BOOST_TEST(cString("name") == d1.GetName());
+ BOOST_TEST(cString("desc") == d1.GetDesc());
+ BOOST_TEST(cString("null_value") == d1.GetNull());
+ BOOST_TEST(cString("html_table_flags") == d1.GetHtmlCellFlags());
+
+ std::remove(filename.c_str());
+ }
+ } // utDataEntry_archiving
+} // nDataEntryTests
+
+void cDataEntry::UnitTests(bool full)
+{
+ //if(full) {
+ // std::cout << "nDataEntryTests::utDataEntry_hello_world" << std::endl;
+ // nDataEntryTests::utDataEntry_hello_world::test();
+ //}
+ if(full) {
+ std::cout << "nDataEntryTests::utDataEntry_archiving" << std::endl;
+ nDataEntryTests::utDataEntry_archiving::test();
+ }
+}
+
Modified: development/source/tools/cDataEntry.h
===================================================================
--- development/source/tools/cDataEntry.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDataEntry.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,13 +11,22 @@
#ifndef cDataEntry_h
#define cDataEntry_h
-#include <iostream>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef cString_h
#include "cString.h"
#endif
+#include <iostream>
+
class cDataEntry {
+#if USE_tMemTrack
+ tMemTrack<cDataEntry> mt;
+#endif
private:
cString name; // Short Name
cString desc; // Descriptive Name
@@ -37,6 +46,24 @@
const cString & GetHtmlCellFlags() const { return html_table_flags; }
virtual bool Print(std::ostream& fp) const { (void) fp; return false; }
+
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version)
+ {
+ a.ArkvObj("name", name);
+ a.ArkvObj("desc", desc);
+ a.ArkvObj("null_value", null_value);
+ a.ArkvObj("html_table_flags", html_table_flags);
+ }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline std::ostream& operator << (std::ostream& out, cDataEntry & entry)
Modified: development/source/tools/cDataFile.h
===================================================================
--- development/source/tools/cDataFile.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDataFile.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -142,6 +142,15 @@
* This function makes sure that all cached data is written to the disk.
**/
void Flush() { m_fp.flush(); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cDataFileManager.h
===================================================================
--- development/source/tools/cDataFileManager.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDataFileManager.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -65,6 +65,15 @@
* @return true if file existed, otherwise false.
**/
bool Remove(const cString& name);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline cDataFileManager::cDataFileManager(cString target_dir) : m_target_dir(target_dir)
Modified: development/source/tools/cDataManager_Base.h
===================================================================
--- development/source/tools/cDataManager_Base.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDataManager_Base.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,6 +38,15 @@
virtual bool GetDesc(const cString& name, cString& out_desc) = 0;
bool PrintRow(cDataFile& data_file, cString row_entries, char sep=' ');
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cDefaultMessageDisplay.h
===================================================================
--- development/source/tools/cDefaultMessageDisplay.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDefaultMessageDisplay.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -47,6 +47,15 @@
public:
cDefaultMessageDisplay(std::ostream* stream) : m_out(stream) { ; }
void out(cString& final_msg);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
extern cDefaultMessageDisplay s_info_msg_cout;
Modified: development/source/tools/cDoubleSum.h
===================================================================
--- development/source/tools/cDoubleSum.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cDoubleSum.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -87,6 +87,15 @@
s3 -= w_val * w_val * w_val;
s4 -= w_val * w_val * w_val * w_val;
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cFile.cc
===================================================================
--- development/source/tools/cFile.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cFile.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -47,6 +47,7 @@
return false;
}
+ m_openmode = flags;
filename = _fname;
is_open = true;
@@ -58,6 +59,7 @@
{
if (is_open == true) {
fp.close();
+ is_open = false;
return true;
}
return false;
@@ -74,3 +76,150 @@
in_string = cur_line;
return true;
}
+
+/*
+Unit tests
+*/
+#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 nFileTests {
+ /*
+ Test-helpers.
+ */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cFile_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cFile_Archive", s);
+ }
+
+
+ namespace utFile_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+ }
+
+ namespace utFile_archiving {
+ void test(){
+ std::string filename("./cFile_basic_serialization.xml");
+ int linecount = 3;
+ std::string data_file_name("./cFile_data.txt");
+ {
+ std::ofstream data_file(data_file_name.c_str());
+ for(int i = 0; i < linecount; i++){
+ data_file << 2 * i << std::endl;
+ }
+ }
+
+ // Open cFile_data.txt for reading.
+ cFile f(data_file_name.c_str());
+
+ cFile f1, f2, f3;
+ cString s1, s2, s3;
+ cString l1, l2, l3;
+
+ // Save initial cFile state.
+ save_stuff<>(f, filename.c_str());
+ // Reload initial state into new cFile.
+ restore_stuff<>(f1, filename.c_str());
+
+ // Save cFile state after reading first line.
+ f.ReadLine(s1);
+ save_stuff<>(f, filename.c_str());
+ // Reload second state into new cFile.
+ restore_stuff<>(f2, filename.c_str());
+
+ // Save cFile state after reading second line.
+ f.ReadLine(s2);
+ save_stuff<>(f, filename.c_str());
+ // Reload third state into new cFile.
+ restore_stuff<>(f3, filename.c_str());
+
+ f.ReadLine(s3);
+
+ // Sanity checks...
+ //BOOST_TEST(false);
+ BOOST_TEST(cString("0") == s1);
+ BOOST_TEST(cString("2") == s2);
+ BOOST_TEST(cString("4") == s3);
+
+ // Verify reading expected lines from various reloaded states.
+ f3.ReadLine(l3);
+ f2.ReadLine(l2);
+ f1.ReadLine(l1);
+ BOOST_TEST(l1 == s1);
+ BOOST_TEST(l2 == s2);
+ BOOST_TEST(l3 == s3);
+
+ std::remove(filename.c_str());
+ std::remove(data_file_name.c_str());
+ }
+ } // utFile_archiving
+
+ namespace utFile_archiving_closed_file {
+ void test(){
+ std::string data_file_name("./cFile_data.txt");
+ {
+ std::ofstream data_file(data_file_name.c_str());
+ for(int i = 0; i < 3; i++){
+ data_file << 2 * i << std::endl;
+ }
+ }
+
+ std::string filename("./cFile_serialize_closed_file.xml");
+
+ // Open cFile_data.txt for reading.
+ cFile f(data_file_name.c_str());
+ // Close file.
+ f.Close();
+ BOOST_TEST(!f.IsOpen());
+
+ cFile f1;
+
+ // Save cFile state.
+ save_stuff<>(f, filename.c_str());
+ // Reload state into new cFile.
+ restore_stuff<>(f1, filename.c_str());
+ // Verify new cFile has matching filename.
+ BOOST_TEST(f.GetFilename() == f1.GetFilename());
+ // Verify new cFile is closed.
+ BOOST_TEST(!f1.IsOpen());
+
+ std::remove(filename.c_str());
+ std::remove(data_file_name.c_str());
+ }
+ } // utFile_archiving_closed_file
+} // nFileTests
+
+void cFile::UnitTests(bool full)
+{
+ //if(full) {
+ // std::cout << "nFileTests::utFile_hello_world" << std::endl;
+ // nFileTests::utFile_hello_world::test();
+ //}
+ if(full) {
+ std::cout << "nFileTests::utFile_archiving" << std::endl;
+ nFileTests::utFile_archiving::test();
+ }
+ if(full) {
+ std::cout << "nFileTests::utFile_archiving_closed_file" << std::endl;
+ nFileTests::utFile_archiving_closed_file::test();
+ }
+}
Modified: development/source/tools/cFile.h
===================================================================
--- development/source/tools/cFile.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cFile.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,12 +11,18 @@
#ifndef cFile_h
#define cFile_h
-#include <fstream>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef cString_h
#include "cString.h"
#endif
+#include <fstream>
+
/**
* This class encapsulates file handling. In comparison to @ref cDataFile
* it has somewhat different features. It is more intended for reading files.
@@ -26,12 +32,16 @@
class cFile
{
+#if USE_tMemTrack
+ tMemTrack<cFile> mt;
+#endif
private:
cFile(const cFile&); // @not_implemented
cFile& operator=(const cFile&); // @not_implemented
protected:
std::fstream fp;
+ std::ios::openmode m_openmode;
cString filename;
bool is_open; // Have we successfully opened this file?
bool verbose; // Should file be verbose about warnings to users?
@@ -64,8 +74,6 @@
* @param _filename The name of the file to open.
* @param mode The opening mode.
**/
- //bool Open(cString _filename, int mode=(ios::in|ios::nocreate));
- // nocreate is no longer in the class ios -- k
bool Open(cString _filename, std::ios::openmode mode=(std::ios::in));
/**
@@ -85,6 +93,74 @@
bool Eof() const { return (fp.eof()); }
void SetVerbose(bool _v=true) { verbose = _v; }
+
+ // Serialization
+public:
+ // Save to archive
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ /*
+ __is_open and __verbose are workarounds for bool-serialization bugs.
+ @kgn
+ */
+ int __is_open = (is_open == false)?(0):(1);
+ int __verbose = (verbose == false)?(0):(1);
+ a.ArkvObj("filename", filename);
+ a.ArkvObj("verbose", __verbose);
+ a.ArkvObj("is_open", __is_open);
+ a.ArkvObj("m_openmode", m_openmode);
+ if(is_open){
+ /*
+ If the file is open, record current read-position.
+ */
+ int position = fp.rdbuf()->pubseekoff(0,std::ios::cur);
+ a.ArkvObj("position", position);
+ }
+ }
+
+ // Load from archive
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ /*
+ __is_open and __verbose are workarounds for bool-serialization bugs.
+ @kgn
+ */
+ int __is_open;
+ int __verbose;
+ a.ArkvObj("filename", filename);
+ a.ArkvObj("verbose", __verbose);
+ a.ArkvObj("is_open", __is_open);
+ a.ArkvObj("m_openmode", m_openmode);
+ is_open = (__is_open == 0)?(false):(true);
+ verbose = (__verbose == 0)?(false):(true);
+ if(is_open){
+ /*
+ After opening file, seek to saved read-position.
+ */
+ int position;
+ a.ArkvObj("position", position);
+ is_open = false;
+ // Only seek if open succeeds.
+ if(Open(filename, m_openmode)){
+ fp.rdbuf()->pubseekpos(position);
+ }
+ }
+ }
+
+ // Ask archive to handle loads and saves separately
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cFixedBlock.h
===================================================================
--- development/source/tools/cFixedBlock.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cFixedBlock.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -24,6 +24,15 @@
inline int GetStart() { return start_point; }
inline void SetStart(int in_sp) { start_point = in_sp; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cFixedCoords.h
===================================================================
--- development/source/tools/cFixedCoords.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cFixedCoords.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -84,6 +84,15 @@
block_num += offset / fixed_size;
offset %= fixed_size;
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cGenesis.h
===================================================================
--- development/source/tools/cGenesis.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cGenesis.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -91,6 +91,15 @@
void Read(bool & _var, const cString & _name, const cString & _def="0.0") {
_var = ReadInt(_name, _def.AsInt()) != 0;
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cHelpAlias.h
===================================================================
--- development/source/tools/cHelpAlias.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cHelpAlias.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -32,6 +32,15 @@
cHelpType * GetType() const;
bool IsAlias() const { return true; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cHelpEntry.h
===================================================================
--- development/source/tools/cHelpEntry.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cHelpEntry.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -35,6 +35,15 @@
virtual bool IsAlias() const = 0;
cString GetHTMLFilename() const { return cStringUtil::Stringf("help.%s.html", static_cast<const char*>(GetKeyword())); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cHelpFullEntry.h
===================================================================
--- development/source/tools/cHelpFullEntry.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cHelpFullEntry.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,15 @@
cHelpType* GetType() const { return type; }
bool IsAlias() const { return false; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cHelpManager.h
===================================================================
--- development/source/tools/cHelpManager.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cHelpManager.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -53,6 +53,15 @@
void SetVerbose(bool _verbose = true) { verbose = _verbose; }
bool GetVerbose() const { return verbose; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cHelpType.h
===================================================================
--- development/source/tools/cHelpType.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cHelpType.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -42,6 +42,15 @@
cHelpEntry * FindEntry(const cString & entry_name);
void PrintHTML();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cHistogram.h
===================================================================
--- development/source/tools/cHistogram.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cHistogram.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -54,6 +54,15 @@
inline int GetMinBin() { return min_bin; }
inline int GetMaxBin() { return max_bin; }
inline int GetNumBins() { return max_bin - min_bin + 1; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline void cHistogram::Clear()
Modified: development/source/tools/cID.h
===================================================================
--- development/source/tools/cID.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cID.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -41,6 +41,15 @@
bool operator>=(const cID &rhs) const { return this >= &rhs; }
bool operator==(const cID &rhs) const { return this == &rhs; }
bool operator!=(const cID &rhs) const { return this != &rhs; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cIndexedBlockStruct.h
===================================================================
--- development/source/tools/cIndexedBlockStruct.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cIndexedBlockStruct.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -103,6 +103,15 @@
}
else fixed_size = 1;
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
inline int cIndexedBlockStruct::Find(cFixedCoords & search_coords) const
Modified: development/source/tools/cInitFile.cc
===================================================================
--- development/source/tools/cInitFile.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cInitFile.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -251,3 +251,152 @@
return found;
}
+
+
+/*
+Unit tests
+*/
+#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 nInitFileTests {
+ /*
+ Test-helpers.
+ */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cInitFile_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cInitFile_Archive", s);
+ }
+
+
+ namespace utInitFile_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+ }
+
+ namespace utInitFile_archiving {
+ void test(){
+ int linecount = 3;
+ std::string data_file_name("./cInitFile_data.txt");
+ {
+ std::ofstream data_file(data_file_name.c_str());
+ for(int i = 0; i < linecount; i++){
+ data_file << 2 * i << std::endl;
+ }
+ }
+
+ std::string filename("./cInitFile_basic_serialization.xml");
+
+ // Open cInitFile_data.txt for reading.
+ cInitFile f(data_file_name.c_str());
+
+ cInitFile f1, f2, f3;
+ cString s1, s2, s3;
+ cString l1, l2, l3;
+
+ // Save initial cInitFile state.
+ save_stuff<>(f, filename.c_str());
+ // Reload initial state into new cInitFile.
+ restore_stuff<>(f1, filename.c_str());
+
+ // Save cInitFile state after reading first line.
+ f.ReadLine(s1);
+ save_stuff<>(f, filename.c_str());
+ // Reload second state into new cInitFile.
+ restore_stuff<>(f2, filename.c_str());
+
+ // Save cInitFile state after reading second line.
+ f.ReadLine(s2);
+ save_stuff<>(f, filename.c_str());
+ // Reload third state into new cInitFile.
+ restore_stuff<>(f3, filename.c_str());
+
+ f.ReadLine(s3);
+
+ // Sanity checks...
+ //BOOST_TEST(false);
+ BOOST_TEST(cString("0") == s1);
+ BOOST_TEST(cString("2") == s2);
+ BOOST_TEST(cString("4") == s3);
+
+ // Verify reading expected lines from various reloaded states.
+ f3.ReadLine(l3);
+ f2.ReadLine(l2);
+ f1.ReadLine(l1);
+ BOOST_TEST(l1 == s1);
+ BOOST_TEST(l2 == s2);
+ BOOST_TEST(l3 == s3);
+
+ std::remove(filename.c_str());
+ std::remove(data_file_name.c_str());
+ }
+ } // utInitFile_archiving
+
+ namespace utInitFile_archiving_closed_file {
+ void test(){
+ std::string data_file_name("./cInitFile_data.txt");
+ {
+ std::ofstream data_file(data_file_name.c_str());
+ for(int i = 0; i < 3; i++){
+ data_file << 2 * i << std::endl;
+ }
+ }
+
+ std::string filename("./cInitFile_serialize_closed_file.xml");
+
+ // Open cInitFile_data.txt for reading.
+ cInitFile f(data_file_name.c_str());
+ // Close file.
+ f.Close();
+ BOOST_TEST(!f.IsOpen());
+
+ cInitFile f1;
+
+ // Save cInitFile state.
+ save_stuff<>(f, filename.c_str());
+ // Reload state into new cInitFile.
+ restore_stuff<>(f1, filename.c_str());
+ // Verify new cInitFile has matching filename.
+ BOOST_TEST(f.GetFilename() == f1.GetFilename());
+ // Verify new cInitFile is closed.
+ BOOST_TEST(!f1.IsOpen());
+
+ std::remove(filename.c_str());
+ std::remove(data_file_name.c_str());
+ }
+ } // utInitFile_archiving_closed_file
+} // nInitFileTests
+
+void cInitFile::UnitTests(bool full)
+{
+ //if(full) {
+ // std::cout << "nInitFileTests::utInitFile_hello_world" << std::endl;
+ // nInitFileTests::utInitFile_hello_world::test();
+ //}
+ if(full) {
+ std::cout << "nInitFileTests::utInitFile_archiving" << std::endl;
+ nInitFileTests::utInitFile_archiving::test();
+ }
+ if(full) {
+ std::cout << "nInitFileTests::utInitFile_archiving_closed_file" << std::endl;
+ nInitFileTests::utInitFile_archiving_closed_file::test();
+ }
+}
Modified: development/source/tools/cInitFile.h
===================================================================
--- development/source/tools/cInitFile.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cInitFile.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,7 +11,11 @@
#ifndef cInitFile_h
#define cInitFile_h
-#include <iostream>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef cFile_h
#include "cFile.h"
@@ -26,17 +30,44 @@
#include "tArray.h"
#endif
+#include <iostream>
+
/**
* A class to handle initialization files.
**/
class cInitFile : public cFile
{
+#if USE_tMemTrack
+ tMemTrack<cInitFile> mt;
+#endif
private:
struct sFileLineInfo {
cString line;
int line_num;
mutable bool used;
+
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const
+ {
+ int __used = (used == false)?(0):(1);
+ a.ArkvObj("line", line);
+ a.ArkvObj("line_num", line_num);
+ a.ArkvObj("used", __used);
+ }
+ template<class Archive>
+ void load(Archive & a, const unsigned int version)
+ {
+ int __used;
+ a.ArkvObj("line", line);
+ a.ArkvObj("line_num", line_num);
+ a.ArkvObj("used", __used);
+ used = (__used == false)?(0):(1);
+ }
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version)
+ { a.SplitLoadSave(*this, version); }
+
};
tArray<sFileLineInfo> line_array;
@@ -163,6 +194,27 @@
const cString & GetFiletype() { return filetype; }
cStringList & GetFormat() { return file_format; }
+
+
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version)
+ {
+ a.ArkvBase("cFile", (cFile &)(*this), *this);
+ a.ArkvObj("line_array", line_array);
+ a.ArkvObj("extra_lines", extra_lines);
+ a.ArkvObj("filetype", filetype);
+ a.ArkvObj("file_format", file_format);
+ a.ArkvObj("active_line", active_line);
+ }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cIntSum.h
===================================================================
--- development/source/tools/cIntSum.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cIntSum.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -78,6 +78,15 @@
s3 -= w_val * w_val * w_val;
s4 -= w_val * w_val * w_val * w_val;
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cIntegratedSchedule.h
===================================================================
--- development/source/tools/cIntegratedSchedule.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cIntegratedSchedule.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -56,6 +56,15 @@
double GetStatus(int id);
bool OK();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cIntegratedScheduleNode.h
===================================================================
--- development/source/tools/cIntegratedScheduleNode.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cIntegratedScheduleNode.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -81,6 +81,15 @@
inline int GetProcessCount() { return process_count; }
inline cIntegratedScheduleNode * GetNext() { return next; }
inline cIntegratedScheduleNode * GetPrev() { return prev; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cMerit.h
===================================================================
--- development/source/tools/cMerit.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cMerit.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -79,6 +79,15 @@
return ( gestation_time != 0 ) ? value / ((double) gestation_time) : 0; }
std::ostream& BinaryPrint(std::ostream& os = std::cout) const ;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
std::ostream& operator<<(std::ostream& os, const cMerit & merit);
Modified: development/source/tools/cMessageClass.h
===================================================================
--- development/source/tools/cMessageClass.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cMessageClass.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -33,6 +33,15 @@
bool const m_no_prefix;
private:
bool _configured;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
/*
Modified: development/source/tools/cMessageClosure.h
===================================================================
--- development/source/tools/cMessageClosure.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cMessageClosure.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -89,6 +89,15 @@
cMessageClosure &va(const char *fmt, ...);
private:
void prefix(void);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
/*
Modified: development/source/tools/cMessageDisplay.h
===================================================================
--- development/source/tools/cMessageDisplay.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cMessageDisplay.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -31,6 +31,15 @@
virtual void out(cString &final_msg){}
virtual void abort(){ abort(); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
void setInfoDisplay(cMessageDisplay &info);
Modified: development/source/tools/cMessageType.h
===================================================================
--- development/source/tools/cMessageType.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cMessageType.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -23,6 +23,15 @@
const char* m_type_name;
const cMessageClass& m_message_class;
bool m_is_active;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cProbSchedule.h
===================================================================
--- development/source/tools/cProbSchedule.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cProbSchedule.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -44,6 +44,15 @@
void Adjust(int item_id, const cMerit& merit);
int GetNextID();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cRandom.cc
===================================================================
--- development/source/tools/cRandom.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cRandom.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -253,3 +253,163 @@
return true;
}
+
+
+
+/*
+Unit tests
+*/
+#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 utRandom_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+}
+
+namespace utRandom_archiving {
+ /*
+ Test-helpers.
+ */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cRandom_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cRandom_Archive", s);
+ }
+
+ void test(){
+ {
+ std::string filename("./cRandom_basic_serialization.xml");
+
+ // Using seed drawn from date and time.
+ // No, using a problematic seed found.
+ cRandom r(13396544);
+
+ /*
+ Exercise the random number generator a little bit before saving
+ and restoring.
+ */
+ int seed = r.GetSeed();
+ int original_seed = r.GetOriginalSeed();
+ double d = r.GetDouble();
+ double dm = r.GetDouble(1.0);
+ double dr = r.GetDouble(1.0, 2.0);
+ int i = r.GetInt(100);
+ int ir = r.GetInt(100, 200);
+ bool p = r.P(0.5);
+ bool up = r.uP(0.0000005);
+ double rn = r.GetRandNormal();
+ double rnr = r.GetRandNormal(10.0, 2.0);
+ unsigned int rpnp = r.GetRandPoisson(10.0, 0.5);
+ unsigned int rpm = r.GetRandPoisson(0.5);
+ unsigned int frb = r.GetFullRandBinomial(10.0, 3.0);
+ unsigned int rb = r.GetRandBinomial(10.0, 3.0);
+
+ /* Save random number generator state. */
+ save_stuff<>(r, filename.c_str());
+
+ /* Get some random numbers... */
+ seed = r.GetSeed();
+ original_seed = r.GetOriginalSeed();
+ d = r.GetDouble();
+ dm = r.GetDouble(1.0);
+ dr = r.GetDouble(1.0, 2.0);
+ i = r.GetInt(100);
+ ir = r.GetInt(100, 200);
+ p = r.P(0.5);
+ up = r.uP(0.0000005);
+ tArray<int> choose(10);
+ r.Choose(100, choose);
+ rn = r.GetRandNormal();
+ rnr = r.GetRandNormal(10.0, 2.0);
+ rpnp = r.GetRandPoisson(10.0, 0.5);
+ rpm = r.GetRandPoisson(0.5);
+ frb = r.GetFullRandBinomial(10.0, 3.0);
+ rb = r.GetRandBinomial(10.0, 3.0);
+
+ /* Reload saved random number generator state. */
+ cRandom r2(0);
+ restore_stuff<>(r2, filename.c_str());
+
+ /*
+ Get some random numbers... Should be the same as those read above.
+ */
+ int seed2 = r2.GetSeed();
+ int original_seed2 = r2.GetOriginalSeed();
+ double d2 = r2.GetDouble();
+ double dm2 = r2.GetDouble(1.0);
+ double dr2 = r2.GetDouble(1.0, 2.0);
+ int i2 = r2.GetInt(100);
+ int ir2 = r2.GetInt(100, 200);
+ bool p2 = r2.P(0.5);
+ bool up2 = r2.uP(0.0000005);
+ tArray<int> choose2(10);
+ r2.Choose(100, choose2);
+ double rn2 = r2.GetRandNormal();
+ double rnr2 = r2.GetRandNormal(10.0, 2.0);
+ unsigned int rpnp2 = r2.GetRandPoisson(10.0, 0.5);
+ unsigned int rpm2 = r2.GetRandPoisson(0.5);
+ unsigned int frb2 = r2.GetFullRandBinomial(10.0, 3.0);
+ unsigned int rb2 = r2.GetRandBinomial(10.0, 3.0);
+
+ /* Compare results. */
+ BOOST_TEST(seed2 == seed);
+ BOOST_TEST(original_seed2 == original_seed);
+ BOOST_TEST(d2 == d);
+ BOOST_TEST(dm2 == dm);
+ BOOST_TEST(dr2 == dr);
+ BOOST_TEST(i2 == i);
+ BOOST_TEST(ir2 == ir);
+ BOOST_TEST(p2 == p);
+ BOOST_TEST(up2 == up);
+ for(int i = 0; i < choose.GetSize(); i++){
+ BOOST_TEST(choose2[i] == choose[i]);
+ }
+ BOOST_TEST(rn2 == rn);
+ BOOST_TEST(rnr2 == rnr);
+ BOOST_TEST(rpnp2 == rpnp);
+ BOOST_TEST(rpm2 == rpm);
+ //std::cout<<"rnr2: "<<rnr2<<", rnr: "<<rnr<<std::endl;
+ //std::cout<<"rpnp2: "<<rpnp2<<", rpnp: "<<rpnp<<std::endl;
+ //std::cout<<"rpm2: "<<rpm2<<", rpm: "<<rpm<<std::endl;
+ BOOST_TEST(frb2 == frb);
+ BOOST_TEST(rb2 == rb);
+
+ /*
+ Print random number seeds to stdout, in case we run across a seed
+ that breaks things in weird ways.
+ */
+ std::cout << "utRandom_archiving info: seed " << seed << ", seed2 " << seed2
+ << ", original_seed " << original_seed << ", original_seed2 "
+ << original_seed2 << std::endl;
+
+ std::remove(filename.c_str());
+ }
+ }
+}
+
+void cRandom::UnitTests(bool full)
+{
+ //if(full) utRandom_hello_world::test();
+ if(full) {
+ std::cout << "utRandom_archiving" << std::endl;
+ utRandom_archiving::test();
+ }
+}
Modified: development/source/tools/cRandom.h
===================================================================
--- development/source/tools/cRandom.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cRandom.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,6 +11,12 @@
#ifndef cRandom_h
#define cRandom_h
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
#include <time.h>
#include <limits.h>
#include <math.h>
@@ -24,6 +30,9 @@
class cRandom
{
+#if USE_tMemTrack
+ tMemTrack<cRandom> mt;
+#endif
protected:
// Internal memebers
int seed;
@@ -204,6 +213,27 @@
* @see cRandom::GetFullRandBinomial
**/
unsigned int GetRandBinomial(const double n, const double p); // Approx
+
+ /**
+ * Serialization to or from an archive.
+ **/
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("seed", seed);
+ a.ArkvObj("original_seed", original_seed);
+ a.ArkvObj("inext", inext);
+ a.ArkvObj("inextp", inextp);
+ a.ArkvObj("ma", ma);
+ a.ArkvObj("expRV", expRV);
+ }
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/tools/cRefBlock.h
===================================================================
--- development/source/tools/cRefBlock.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cRefBlock.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -39,6 +39,15 @@
ref_num = in_block.GetRef();
size = in_block.GetSize();
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cRunningAverage.h
===================================================================
--- development/source/tools/cRunningAverage.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cRunningAverage.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -56,6 +56,15 @@
// Notation Shortcuts
double Ave() const { return Average(); }
double Var() const { return Variance(); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cScaledBlock.h
===================================================================
--- development/source/tools/cScaledBlock.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cScaledBlock.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -44,6 +44,15 @@
data = in_block.GetData();
size = in_block.GetSize();
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cSchedule.h
===================================================================
--- development/source/tools/cSchedule.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cSchedule.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -43,6 +43,15 @@
cChangeList *GetChangeList() { return m_change_list; }
void SetSize(int _item_count);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cString.cc
===================================================================
--- development/source/tools/cString.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cString.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -644,3 +644,203 @@
return out;
}
+
+
+/*
+Unit tests
+*/
+#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 utString_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+}
+
+namespace utString_archiving {
+ /*
+ Test-helpers.
+ */
+ class A {
+ public:
+ cString m_s1, m_s2;
+ cString *m_ps1, *m_ps2;
+ static int s_instance_ct;
+ public:
+ A():m_s1("blah."), m_s2(m_s1), m_ps1(new cString("ick.")), m_ps2(m_ps1) { s_instance_ct++; }
+ ~A(){ s_instance_ct--; }
+ public:
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("m_s1", m_s1);
+ a.ArkvObj("m_s2", m_s2);
+ a.ArkvObj("m_ps1", m_ps1);
+ a.ArkvObj("m_ps2", m_ps2);
+ }
+ };
+ int A::s_instance_ct(0);
+
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("s", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("s", s);
+ }
+
+ void test(){
+ {
+ BOOST_TEST(true);
+ std::string filename("./cString_basic_serialization.xml");
+
+ BOOST_TEST(0 == A::s_instance_ct);
+ A *a(new A);
+ BOOST_TEST(1 == A::s_instance_ct);
+
+ /*
+ Both instances of cString should share a single cStringData instance.
+ */
+ BOOST_TEST(cString("blah.") == a->m_s1);
+ BOOST_TEST(cString("blah.") == a->m_s2);
+ const char *s1(a->m_s1);
+ const char *s2(a->m_s2);
+ BOOST_TEST(s1 == s2);
+
+ /*
+ Both pointers should point to one cString instance.
+ */
+ BOOST_TEST(cString("ick.") == *a->m_ps1);
+ BOOST_TEST(cString("ick.") == *a->m_ps2);
+ const char *s3(*a->m_ps1);
+ const char *s4(*a->m_ps2);
+ BOOST_TEST(s3 == s4);
+
+ save_stuff<>(a, filename.c_str());
+ delete a;
+ BOOST_TEST(0 == A::s_instance_ct);
+
+ restore_stuff<>(a, filename.c_str());
+ BOOST_TEST(1 == A::s_instance_ct);
+
+ /*
+ Both instances of cString should share a single cStringData instance.
+ */
+ BOOST_TEST(cString("blah.") == a->m_s1);
+ BOOST_TEST(cString("blah.") == a->m_s2);
+ /*
+ We have decided to not track cStringData instance sharing;
+ consequently we now expect that if two strings sharing data are
+ both saved and then reloaded, the reloaded versions no longer
+ share data.
+ This prevents a certain kind of memory leak.
+ @kgn
+ */
+ const char *s5(a->m_s1);
+ const char *s6(a->m_s2);
+ BOOST_TEST(s5 != s6);
+
+ /*
+ Both pointers should point to one cString instance.
+ */
+ BOOST_TEST(cString("ick.") == *a->m_ps1);
+ BOOST_TEST(cString("ick.") == *a->m_ps2);
+ const char *s7(*a->m_ps1);
+ const char *s8(*a->m_ps2);
+ BOOST_TEST(s7 == s8);
+
+ delete a;
+ BOOST_TEST(0 == A::s_instance_ct);
+
+ std::remove(filename.c_str());
+ }
+ {
+ BOOST_TEST(true);
+ std::string filename("./cString_basic_serialization_2.xml");
+
+ BOOST_TEST(0 == A::s_instance_ct);
+ A *a(new A);
+ BOOST_TEST(1 == A::s_instance_ct);
+
+ /*
+ Both instances of cString were sharing a single cStringData
+ instance, but assigning a new string to the first should create a
+ new, unshared cStringData instance; so now each cString should
+ have its own cStringData.
+ */
+ a->m_s1 = "bleah.";
+ BOOST_TEST(cString("bleah.") == a->m_s1);
+ BOOST_TEST(cString("blah.") == a->m_s2);
+ const char *s1(a->m_s1);
+ const char *s2(a->m_s2);
+ BOOST_TEST(s1 != s2);
+
+ /*
+ Both pointers should point to one cString instance.
+ */
+ *a->m_ps1 = "ack.";
+ BOOST_TEST(cString("ack.") == *a->m_ps1);
+ BOOST_TEST(cString("ack.") == *a->m_ps2);
+ const char *s3(*a->m_ps1);
+ const char *s4(*a->m_ps2);
+ BOOST_TEST(s3 == s4);
+
+ save_stuff<>(a, filename.c_str());
+ delete a;
+ BOOST_TEST(0 == A::s_instance_ct);
+
+ restore_stuff<>(a, filename.c_str());
+ BOOST_TEST(1 == A::s_instance_ct);
+
+ /*
+ Each cString should have its own cStringData.
+ */
+ BOOST_TEST(cString("bleah.") == a->m_s1);
+ BOOST_TEST(cString("blah.") == a->m_s2);
+ const char *s5(a->m_s1);
+ const char *s6(a->m_s2);
+ BOOST_TEST(s5 != s6);
+
+ /*
+ Both pointers should point to one cString instance.
+ */
+ BOOST_TEST(cString("ack.") == *a->m_ps1);
+ BOOST_TEST(cString("ack.") == *a->m_ps2);
+ const char *s7(*a->m_ps1);
+ const char *s8(*a->m_ps2);
+ BOOST_TEST(s7 == s8);
+
+
+ delete a;
+ BOOST_TEST(0 == A::s_instance_ct);
+
+ std::remove(filename.c_str());
+ }
+ }
+}
+
+void cString::UnitTests(bool full)
+{
+ //if(full) {
+ // std::cout << "utString_hello_world" << std::endl;
+ // utString_hello_world::test();
+ //}
+ if(full) {
+ std::cout << "utString_archiving" << std::endl;
+ utString_archiving::test();
+ }
+}
Modified: development/source/tools/cString.h
===================================================================
--- development/source/tools/cString.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cString.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -16,6 +16,12 @@
#include <string.h>
#include <assert.h>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
#define MAX_STRING_LENGTH 4096
#define MAX_STRING_REF_COUNT 32767
#define CONTINUE_LINE_CHAR '\\'
@@ -27,6 +33,9 @@
class cString
{
+#if USE_tMemTrack
+ tMemTrack<cString> mt;
+#endif
protected:
inline void CopyOnWrite();
@@ -510,8 +519,29 @@
cString Substring(int start, int size) const ;
bool IsSubstring(const cString & in_string, int start) const;
-
-
+
+ /*
+ We have decided to not serialize information about data-sharing
+ between cStrings (via cStringData). This leads to plausible memory
+ bloat when formerly shared strings are reloaded (and are no longer
+ shared), but in the case of Avida, there shouldn't be much bloat. @kgn
+ */
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ std::string s(value->GetData());
+ a.ArkvObj("value", s);
+ }
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ std::string s;
+ a.ArkvObj("value", s);
+ (*this)=s.c_str();
+ }
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
+
// {{{ -- INTERNALS -------------------------------------------------------
protected:
// -- Internal Functions --
@@ -543,6 +573,14 @@
// }}} End Internals
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/tools/cStringIterator.h
===================================================================
--- development/source/tools/cStringIterator.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cStringIterator.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -44,6 +44,15 @@
const cString & Prev() { list_it.Prev(); return Get(); }
bool AtRoot() const { return list_it.AtRoot(); }
bool AtEnd() const { return list_it.AtEnd(); }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cStringList.cc
===================================================================
--- development/source/tools/cStringList.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cStringList.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -71,3 +71,118 @@
}
return "";
}
+
+
+/*
+Unit tests
+*/
+#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 nStringListTests {
+ /*
+ Test-helpers.
+ */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cStringList_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cStringList_Archive", s);
+ }
+
+
+ namespace utStringList_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+ }
+
+ namespace utStringList_archiving {
+ void test(){
+ char numstr[] = "number 0";
+ cString s;
+ cStringList sl;
+ cStringIterator it(sl);
+ std::string filename("./cStringList_basic_serialization.xml");
+ int i, listsize = 10;
+
+ /*
+ Construct basic list.
+ */
+ BOOST_TEST(0 == sl.GetSize());
+ for(i=0; i<listsize; i++){
+ numstr[7] = '0' + i;
+ s = cString(numstr);
+ sl.PushRear(s);
+ }
+ BOOST_TEST(listsize == sl.GetSize());
+
+ /*
+ Verify basic list contents.
+ */
+ it.Reset();
+ for(i=0; !it.AtEnd(); i++){
+ s = it.Next();
+ numstr[7] = '0' + i;
+ BOOST_TEST(cString(numstr) == s);
+ }
+ BOOST_TEST(i == listsize);
+
+ /*
+ Save basic list.
+ */
+ save_stuff<>(sl, filename.c_str());
+ sl.Clear();
+ BOOST_TEST(0 == sl.GetSize());
+
+ /*
+ Reload basic list.
+ */
+ restore_stuff<>(sl, filename.c_str());
+ BOOST_TEST(listsize == sl.GetSize());
+
+ /*
+ Verify contents of reloaded basic list.
+ */
+ it.Reset();
+ for(i=0; !it.AtEnd(); i++){
+ s = it.Next();
+ numstr[7] = '0' + i;
+ BOOST_TEST(cString(numstr) == s);
+ }
+ BOOST_TEST(i == listsize);
+
+ sl.Clear();
+ BOOST_TEST(0 == sl.GetSize());
+
+ std::remove(filename.c_str());
+ }
+ } // utStringList_archiving
+} // nStringListTests
+
+void cStringList::UnitTests(bool full)
+{
+ //if(full) {
+ // std::cout << "nStringListTests::utStringList_hello_world" << std::endl;
+ // nStringListTests::utStringList_hello_world::test();
+ //}
+ if(full) {
+ std::cout << "nStringListTests::utStringList_archiving" << std::endl;
+ nStringListTests::utStringList_archiving::test();
+ }
+}
Modified: development/source/tools/cStringList.h
===================================================================
--- development/source/tools/cStringList.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cStringList.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,6 +11,12 @@
#ifndef cStringList_h
#define cStringList_h
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
#ifndef cString_h
#include "cString.h"
#endif
@@ -21,6 +27,9 @@
class cStringList
{
+#if USE_tMemTrack
+ tMemTrack<cStringList> mt;
+#endif
private:
tList<cString> string_list;
@@ -57,6 +66,20 @@
void Clear() {
while (string_list.GetSize() > 0) delete string_list.Pop();
}
+
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("string_list", string_list);
+ }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cStringUtil.h
===================================================================
--- development/source/tools/cStringUtil.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cStringUtil.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -59,6 +59,15 @@
static cString Convert(bool in_bool);
static cString Convert(int in_int);
static cString Convert(double in_double);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Added: development/source/tools/cTemplateTests.cc
===================================================================
--- development/source/tools/cTemplateTests.cc 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cTemplateTests.cc 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,750 @@
+/*
+ * cTemplateTests.cc
+ * Avida
+ *
+ * Copyright 2005-2006 Michigan State University. All rights reserved.
+ * Copyright 1993-2003 California Institute of Technology
+ *
+ */
+
+#include "cTemplateTests.h"
+
+
+/*
+Unit tests
+*/
+#include "cXMLArchive.h"
+#include "tArray.h"
+#include "tBuffer.h"
+#include "tDictionary.h"
+#include "tHashTable.h"
+#include "tList.h"
+#include "tManagedPointerArray.h"
+#include "tMatrix.h"
+#include "tMemTrack.h"
+#include "tSmartArray.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 nTemplateTests {
+ /*
+ Test-helpers.
+ */
+ class A {
+ tMemTrack<A> mt;
+ public:
+ int m_i;
+ int m_j;
+ public:
+ A():m_i(-1),m_j(-1){}
+ A(const A &in):m_i(in.m_i),m_j(in.m_j){}
+ A& operator=(const A& in){
+ m_i = in.m_i;
+ m_j = in.m_j;
+ return *this;
+ }
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("m_i", m_i);
+ a.ArkvObj("m_j", m_j);
+ }
+ };
+ // ostream output, needed for tHashTable::OK()
+ std::ostream& operator << (std::ostream& out, const A & a){
+ out << "(" << a.m_i << "," << a.m_j << ")";
+ return out;
+ }
+
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("TemplateTest", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("TemplateTest", s);
+ }
+
+
+ namespace utTemplateTests_hello_world {
+ void test(){
+ BOOST_TEST(true);
+ BOOST_TEST(false);
+ }
+ }
+
+
+ namespace utMemTrack {
+ void test(){
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ {
+ A a;
+ BOOST_TEST(1 == tMemTrack<A>::Instances());
+ }
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ A *p;
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ p = new A();
+ BOOST_TEST(1 == tMemTrack<A>::Instances());
+ delete p;
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ }
+ }
+
+ namespace utList_basic_serialization {
+ void test(){
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ A *a;
+ tList<A> l;
+ tListIterator<A> it(l);
+ std::string filename("./tList_basic_serialization.xml");
+ int i, listsize = 10;
+
+ BOOST_TEST(1 == tMemTrack<tList<A> >::Instances());
+ BOOST_TEST(1 == tMemTrack<tListNode<A> >::Instances());
+
+ /*
+ Construct basic list.
+ */
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ for(i=0; i<listsize; i++){
+ a = new A;
+ a->m_i = i;
+ l.PushRear(a);
+ }
+ BOOST_TEST(listsize == tMemTrack<A>::Instances());
+ BOOST_TEST(1 + listsize == tMemTrack<tListNode<A> >::Instances());
+
+ /*
+ Verify basic list contents.
+ */
+ BOOST_TEST(listsize == tMemTrack<A>::Instances());
+ it.Reset();
+ for(i=0; (a = it.Next()); i++){
+ BOOST_TEST(i == a->m_i);
+ }
+
+ /*
+ Save basic list.
+ */
+ save_stuff<>(l, filename.c_str());
+ it.Reset();
+ for(i=0; (a = it.Next()); i++){
+ delete a;
+ }
+ l.Clear();
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ BOOST_TEST(1 == tMemTrack<tList<A> >::Instances());
+ BOOST_TEST(1 == tMemTrack<tListNode<A> >::Instances());
+
+ /*
+ Reload basic list.
+ */
+ restore_stuff<>(l, filename.c_str());
+ BOOST_TEST(1 == tMemTrack<tList<A> >::Instances());
+ BOOST_TEST(listsize == tMemTrack<A>::Instances());
+ BOOST_TEST(1 + listsize == tMemTrack<tListNode<A> >::Instances());
+
+ /*
+ Verify contents of reloaded basic list.
+ */
+ for(i=0; i<listsize; i++){
+ a = l.Pop();
+ BOOST_TEST(i == a->m_i);
+ delete a;
+ }
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ BOOST_TEST(1 == tMemTrack<tList<A> >::Instances());
+ BOOST_TEST(1 == tMemTrack<tListNode<A> >::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utList_basic_serialization
+
+ namespace utList_archive_structure {
+ void test(){
+ std::string filename("./tList_archive_structure.xml");
+
+ A *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9, *a10;
+
+ tList<A> l;
+ tListIterator<A> it(l);
+
+ /*
+ Construct list...
+ */
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ a1 = new A;
+ a2 = new A;
+ BOOST_TEST(2 == tMemTrack<A>::Instances());
+ l.PushRear(a1);
+ l.PushRear(a2);
+ l.PushRear(a1);
+ l.PushRear(a2);
+ BOOST_TEST(2 == tMemTrack<A>::Instances());
+
+ /*
+ Verify list structure. It should now contain two copies each,
+ interleaved, of two instances of A.
+ */
+ it.Reset();
+ a3 = it.Next();
+ a4 = it.Next();
+ a5 = it.Next();
+ a6 = it.Next();
+ BOOST_TEST(2 == tMemTrack<A>::Instances());
+
+ a1->m_i = 3;
+ a2->m_i = 5;
+ BOOST_TEST(3 == a3->m_i);
+ BOOST_TEST(5 == a4->m_i);
+ BOOST_TEST(3 == a5->m_i);
+ BOOST_TEST(5 == a6->m_i);
+
+ /*
+ Save to disk, clear, and reload.
+ */
+ save_stuff<>(l, filename.c_str());
+ BOOST_TEST(2 == tMemTrack<A>::Instances());
+
+ l.Clear();
+ BOOST_TEST(2 == tMemTrack<A>::Instances());
+
+ restore_stuff<>(l, filename.c_str());
+
+ /*
+ New list should contain two copies each, interleaved, of the two
+ new instances of A.
+ */
+ BOOST_TEST(4 == tMemTrack<A>::Instances());
+
+ /*
+ Verify new list structure.
+ */
+ it.Reset();
+ a7 = it.Next();
+ a8 = it.Next();
+ a9 = it.Next();
+ a10 = it.Next();
+ BOOST_TEST(4 == tMemTrack<A>::Instances());
+
+ BOOST_TEST(3 == a7->m_i);
+ BOOST_TEST(5 == a8->m_i);
+ BOOST_TEST(3 == a9->m_i);
+ BOOST_TEST(5 == a10->m_i);
+
+ /*
+ Verify that elements of old and new lists are independent.
+ */
+ a1->m_i = 7;
+ a7->m_i = 11;
+ a8->m_i = 13;
+ BOOST_TEST(7 == a3->m_i);
+ BOOST_TEST(5 == a4->m_i);
+ BOOST_TEST(7 == a5->m_i);
+ BOOST_TEST(5 == a6->m_i);
+ BOOST_TEST(11 == a7->m_i);
+ BOOST_TEST(13 == a8->m_i);
+ BOOST_TEST(11 == a9->m_i);
+ BOOST_TEST(13 == a10->m_i);
+
+ l.Clear();
+ /*
+ Delete originals instances of A.
+ */
+ delete a1;
+ delete a2;
+ /*
+ Delete reloaded copies of A.
+ */
+ delete a7;
+ delete a8;
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utList_archive_structure
+
+ namespace utArray_basic_serialization {
+ void test(){
+ std::string filename("./tArray_basic_serialization.xml");
+ int i, arraysize = 10;
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ tArray<A> l(arraysize);
+ BOOST_TEST(arraysize == tMemTrack<A>::Instances());
+
+ /*
+ Construct basic array.
+ */
+ for(i=0; i<arraysize; i++){
+ l[i].m_i = i;
+ }
+
+ /*
+ Verify basic array contents.
+ */
+ for(i=0; i<arraysize; i++){
+ BOOST_TEST(i == l[i].m_i);
+ }
+
+ /*
+ Save basic array.
+ */
+ save_stuff<>(l, filename.c_str());
+ l.ResizeClear(0);
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ /*
+ Reload basic array.
+ */
+ restore_stuff<>(l, filename.c_str());
+ BOOST_TEST(arraysize == tMemTrack<A>::Instances());
+
+ /*
+ Verify contents of reloaded basic array.
+ */
+ for(i=0; i<arraysize; i++){
+ BOOST_TEST(i == l[i].m_i);
+ }
+
+ l.ResizeClear(0);
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utArray_basic_serialization
+
+ namespace utHashTable_basic_serialization {
+ void test(){
+ std::string filename("./tHashTable_basic_serialization.xml");
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ tHashTable<cString, A> d;
+ char keystr[9] = "number 0";
+ int i, dictsize = 10;
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ // Sanity checks.
+ BOOST_TEST(d.OK());
+ BOOST_TEST(0 == d.GetSize());
+ BOOST_TEST(!d.HasEntry("blah"));
+ {
+ A a;
+ BOOST_TEST(!d.Find("blah", a));
+ }
+
+ /*
+ Construct basic dict.
+ */
+ for(i=0; i<dictsize; i++){
+ A a;
+ keystr[7] = '0' + i;
+ a.m_i = i;
+ d.Add(cString(keystr), a);
+ }
+ BOOST_TEST(dictsize == tMemTrack<A>::Instances());
+
+ /*
+ Verify basic dict contents.
+ */
+ for(i=0; i<dictsize; i++){
+ A a;
+ keystr[7] = '0' + i;
+ BOOST_TEST(d.Find(cString(keystr), a));
+ BOOST_TEST(i == a.m_i);
+ }
+ BOOST_TEST(d.OK());
+
+ /*
+ Save basic table.
+ */
+ save_stuff<>(d, filename.c_str());
+ BOOST_TEST(dictsize == tMemTrack<A>::Instances());
+
+ /*
+ Reload basic table.
+ */
+ {
+ tHashTable<cString, A> d2;
+ restore_stuff<>(d2, filename.c_str());
+ BOOST_TEST(2 * dictsize == tMemTrack<A>::Instances());
+ BOOST_TEST(d2.OK());
+
+ /*
+ Verify contents of reloaded basic dict.
+ */
+ for(i=0; i<dictsize; i++){
+ A a;
+ keystr[7] = '0' + i;
+ BOOST_TEST(d2.Find(cString(keystr), a));
+ BOOST_TEST(i == a.m_i);
+ }
+ BOOST_TEST(2 * dictsize == tMemTrack<A>::Instances());
+ }
+
+ BOOST_TEST(dictsize == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utHashTable_basic_serialization
+
+ namespace utDictionary_basic_serialization {
+ void test(){
+ std::string filename("./tDictionary_basic_serialization.xml");
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ tDictionary<A> d;
+ char keystr[9] = "number 0";
+ int i, dictsize = 10;
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ // Sanity checks.
+ BOOST_TEST(d.OK());
+ BOOST_TEST(0 == d.GetSize());
+ BOOST_TEST(!d.HasEntry("blah"));
+ {
+ A a;
+ BOOST_TEST(!d.Find("blah", a));
+ }
+ BOOST_TEST(cString("") == d.NearMatch("blah"));
+
+ /*
+ Construct basic dict.
+ */
+ for(i=0; i<dictsize; i++){
+ A a;
+ keystr[7] = '0' + i;
+ a.m_i = i;
+ d.Add(cString(keystr), a);
+ }
+ BOOST_TEST(dictsize == tMemTrack<A>::Instances());
+
+ /*
+ Verify basic dict contents.
+ */
+ for(i=0; i<dictsize; i++){
+ A a;
+ keystr[7] = '0' + i;
+ BOOST_TEST(d.Find(cString(keystr), a));
+ BOOST_TEST(i == a.m_i);
+ }
+ BOOST_TEST(d.OK());
+
+ /*
+ Save basic list.
+ */
+ save_stuff<>(d, filename.c_str());
+ BOOST_TEST(dictsize == tMemTrack<A>::Instances());
+
+ /*
+ Reload basic list.
+ */
+ {
+ tDictionary<A> d2;
+ restore_stuff<>(d2, filename.c_str());
+ BOOST_TEST(2 * dictsize == tMemTrack<A>::Instances());
+ BOOST_TEST(d2.OK());
+
+ /*
+ Verify contents of reloaded basic dict.
+ */
+ for(i=0; i<dictsize; i++){
+ A a;
+ keystr[7] = '0' + i;
+ BOOST_TEST(d2.Find(cString(keystr), a));
+ BOOST_TEST(i == a.m_i);
+ }
+ BOOST_TEST(2 * dictsize == tMemTrack<A>::Instances());
+ }
+
+ BOOST_TEST(dictsize == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utDictionary_basic_serialization
+
+ namespace utBuffer_basic_serialization {
+ void test(){
+ std::string filename("./tBuffer_basic_serialization.xml");
+ A a;
+ int i, buffer_size = 10;
+
+ BOOST_TEST(1 == tMemTrack<A>::Instances());
+ tBuffer<A> b(buffer_size);
+ BOOST_TEST(1 + buffer_size == tMemTrack<A>::Instances());
+
+ /*
+ Construct basic buffer.
+ */
+ for(i=0; i < buffer_size - 1; i++){
+ a.m_i = i;
+ b.Add(a);
+ }
+
+ /*
+ Verify basic buffer contents.
+ */
+ for(i=0; i < buffer_size - 1; i++){
+ BOOST_TEST(buffer_size - 2 - i == b[i].m_i);
+ }
+ BOOST_TEST(b.GetCapacity() == buffer_size);
+ BOOST_TEST(b.GetTotal() == buffer_size - 1);
+ BOOST_TEST(b.GetNumStored() == buffer_size - 1);
+ BOOST_TEST(b.GetNum() == buffer_size - 1);
+
+ /*
+ Save and clear basic buffer.
+ */
+ save_stuff<>(b, filename.c_str());
+ b.Clear();
+ for(i=0; i < buffer_size - 1; i++){
+ a.m_i = 0;
+ b.Add(a);
+ }
+ for(i=0; i < buffer_size - 1; i++){
+ BOOST_TEST(0 == b[i].m_i);
+ }
+ b.Clear();
+ BOOST_TEST(b.GetCapacity() == buffer_size);
+ BOOST_TEST(b.GetTotal() == 0);
+ BOOST_TEST(b.GetNumStored() == 0);
+ BOOST_TEST(b.GetNum() == 0);
+
+ /*
+ Reload basic buffer.
+ */
+ restore_stuff<>(b, filename.c_str());
+ BOOST_TEST(1 + buffer_size == tMemTrack<A>::Instances());
+
+ /*
+ Verify contents of reloaded basic buffer.
+ */
+ for(i=0; i < buffer_size - 1; i++){
+ BOOST_TEST(buffer_size - 2 - i == b[i].m_i);
+ }
+ BOOST_TEST(b.GetCapacity() == buffer_size);
+ BOOST_TEST(b.GetTotal() == buffer_size - 1);
+ BOOST_TEST(b.GetNumStored() == buffer_size - 1);
+ BOOST_TEST(b.GetNum() == buffer_size - 1);
+
+ std::remove(filename.c_str());
+ }
+ } // utBuffer_basic_serialization
+
+ namespace utManagedPointerArray_basic_serialization {
+ void test(){
+ std::string filename("./tManagedPointerArray_basic_serialization.xml");
+ int i, arraysize = 10;
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ tManagedPointerArray<A> l(arraysize);
+ BOOST_TEST(arraysize == tMemTrack<A>::Instances());
+
+ /*
+ Construct basic array.
+ */
+ for(i=0; i<arraysize; i++){
+ l[i].m_i = i;
+ }
+
+ /*
+ Verify basic array contents.
+ */
+ for(i=0; i<arraysize; i++){
+ BOOST_TEST(i == l[i].m_i);
+ }
+
+ /*
+ Save basic array.
+ */
+ save_stuff<>(l, filename.c_str());
+ l.ResizeClear(0);
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ /*
+ Reload basic array.
+ */
+ restore_stuff<>(l, filename.c_str());
+ BOOST_TEST(arraysize == tMemTrack<A>::Instances());
+
+ /*
+ Verify contents of reloaded basic array.
+ */
+ for(i=0; i<arraysize; i++){
+ BOOST_TEST(i == l[i].m_i);
+ }
+
+ l.ResizeClear(0);
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utManagedPointerArray_basic_serialization
+
+ namespace utSmartArray_basic_serialization {
+ void test(){
+ std::string filename("./tSmartArray_basic_serialization.xml");
+ int i, arraysize = 10;
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ tSmartArray<A> l(arraysize);
+ BOOST_TEST(arraysize == tMemTrack<A>::Instances());
+
+ /*
+ Construct basic array.
+ */
+ for(i=0; i<arraysize; i++){
+ l[i].m_i = i;
+ }
+
+ /*
+ Verify basic array contents.
+ */
+ for(i=0; i<arraysize; i++){
+ BOOST_TEST(i == l[i].m_i);
+ }
+
+ /*
+ Save basic array.
+ */
+ save_stuff<>(l, filename.c_str());
+ l.ResizeClear(0);
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ /*
+ Reload basic array.
+ */
+ restore_stuff<>(l, filename.c_str());
+ BOOST_TEST(arraysize == tMemTrack<A>::Instances());
+
+ /*
+ Verify contents of reloaded basic array.
+ */
+ for(i=0; i<arraysize; i++){
+ BOOST_TEST(i == l[i].m_i);
+ }
+
+ l.ResizeClear(0);
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utSmartArray_basic_serialization
+
+ namespace utMatrix_basic_serialization {
+ void test(){
+ std::string filename("./tMatrix_basic_serialization.xml");
+ int i, j, rows = 3, cols = 5;
+
+ BOOST_TEST(0 == tMemTrack<A>::Instances());
+ tMatrix<A> m(rows, cols);
+ BOOST_TEST(rows * cols == tMemTrack<A>::Instances());
+
+ /*
+ Construct basic matrix.
+ */
+ for(i=0; i<rows; i++){
+ for(j=0; j<cols; j++){
+ m[i][j].m_i = i;
+ m[i][j].m_j = j;
+ }
+ }
+
+ /*
+ Verify basic matrix contents.
+ */
+ for(i=0; i<rows; i++){
+ for(j=0; j<cols; j++){
+ BOOST_TEST(i == m[i][j].m_i);
+ BOOST_TEST(j == m[i][j].m_j);
+ }
+ }
+
+ /*
+ Save basic matrix.
+ */
+ save_stuff<>(m, filename.c_str());
+ m.ResizeClear(1,1);
+ BOOST_TEST(1 == tMemTrack<A>::Instances());
+
+ /*
+ Reload basic matrix.
+ */
+ restore_stuff<>(m, filename.c_str());
+ BOOST_TEST(rows * cols == tMemTrack<A>::Instances());
+
+ /*
+ Verify contents of reloaded basic matrix.
+ */
+ for(i=0; i<rows; i++){
+ for(j=0; j<cols; j++){
+ BOOST_TEST(i == m[i][j].m_i);
+ BOOST_TEST(j == m[i][j].m_j);
+ }
+ }
+
+ m.ResizeClear(1,1);
+ BOOST_TEST(1 == tMemTrack<A>::Instances());
+
+ std::remove(filename.c_str());
+ }
+ } // utMatrix_basic_serialization
+} // nTemplateTests
+
+void cTemplateTests::UnitTests(bool full)
+{
+ //if(full) nTemplateTests::utTemplateTests_hello_world::test();
+ if(full) {
+ std::cout << "nTemplateTests::utMemTrack" << std::endl;
+ nTemplateTests::utMemTrack::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utList_basic_serialization" << std::endl;
+ nTemplateTests::utList_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utList_archive_structure" << std::endl;
+ nTemplateTests::utList_archive_structure::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utArray_basic_serialization" << std::endl;
+ nTemplateTests::utArray_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utHashTable_basic_serialization" << std::endl;
+ nTemplateTests::utHashTable_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utDictionary_basic_serialization" << std::endl;
+ nTemplateTests::utDictionary_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utBuffer_basic_serialization" << std::endl;
+ nTemplateTests::utBuffer_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utManagedPointerArray_basic_serialization" << std::endl;
+ nTemplateTests::utManagedPointerArray_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utSmartArray_basic_serialization" << std::endl;
+ nTemplateTests::utSmartArray_basic_serialization::test();
+ }
+ if(full) {
+ std::cout << "nTemplateTests::utMatrix_basic_serialization" << std::endl;
+ nTemplateTests::utMatrix_basic_serialization::test();
+ }
+}
Added: development/source/tools/cTemplateTests.h
===================================================================
--- development/source/tools/cTemplateTests.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cTemplateTests.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,23 @@
+/*
+ * cTemplateTests.h
+ * Avida
+ *
+ * Copyright 2005-2006 Michigan State University. All rights reserved.
+ * Copyright 1993-2003 California Institute of Technology
+ *
+ */
+
+#ifndef cTemplateTests_h
+#define cTemplateTests_h
+
+class cTemplateTests {
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+};
+
+#endif
Modified: development/source/tools/cThread.h
===================================================================
--- development/source/tools/cThread.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cThread.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -37,6 +37,15 @@
int Start();
void Stop();
void Join();
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cTools.h
===================================================================
--- development/source/tools/cTools.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cTools.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -24,6 +24,15 @@
public:
static bool MkDir(const cString& dirname, bool verbose=false);
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cUInt.h
===================================================================
--- development/source/tools/cUInt.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cUInt.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -188,6 +188,15 @@
return (value >= in_cUInt.AsLong());
}
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
Modified: development/source/tools/cVerifierSuiteRecurser.h
===================================================================
--- development/source/tools/cVerifierSuiteRecurser.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cVerifierSuiteRecurser.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -43,6 +43,15 @@
cVerifierSuiteRecurser(bool recurse): m_cyck(recurse) {}
public:
cCycleCheck m_cyck;
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/cWeightedIndex.h
===================================================================
--- development/source/tools/cWeightedIndex.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/cWeightedIndex.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -49,6 +49,15 @@
int GetParent(int id) { return (id-1) / 2; }
int GetLeftChild(int id) { return 2*id + 1; }
int GetRightChild(int id) { return 2*id + 2; }
+
+public:
+ /**
+ * Run unit tests
+ *
+ * @param full Run full test suite; if false, just the fast tests.
+ **/
+ static void UnitTests(bool full = false);
+
};
#endif
Modified: development/source/tools/tArray.h
===================================================================
--- development/source/tools/tArray.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tArray.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,8 +11,10 @@
#ifndef tArray_h
#define tArray_h
-#ifndef NULL
-#define NULL 0
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
#endif
#include <assert.h>
@@ -23,6 +25,9 @@
template <class T> class tArray
{
+#if USE_tMemTrack
+ tMemTrack<tArray<T> > mt;
+#endif
private:
T* m_data; // Data Elements
int m_size; // Number of Elements
@@ -114,6 +119,39 @@
{
for (int i = 0; i < m_size; i++) m_data[i] = value;
}
+
+ // Save to archive
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ // Save number of elements.
+ unsigned int count = GetSize();
+ a.ArkvObj("count", count);
+ // Save elements.
+ while(count-- > 0){
+ a.ArkvObj("item", (*this)[count]);
+ }
+ }
+
+
+ // Load from archive
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ // Retrieve number of elements.
+ unsigned int count;
+ a.ArkvObj("count", count);
+ ResizeClear(count);
+ // Retrieve elements.
+ while(count-- > 0){
+ a.ArkvObj("item", (*this)[count]);
+ }
+ }
+
+ // Ask archive to handle loads and saves separately
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
+
};
#endif
Modified: development/source/tools/tBuffer.h
===================================================================
--- development/source/tools/tBuffer.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tBuffer.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,8 +11,11 @@
#ifndef tBuffer_h
#define tBuffer_h
-#include <assert.h>
-#include <iostream>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef cString_h
#include "cString.h"
@@ -21,9 +24,15 @@
#include "tArray.h"
#endif
+#include <assert.h>
+#include <iostream>
+
template <class T> class tBuffer
{
+#if USE_tMemTrack
+ tMemTrack<tBuffer<T> > mt;
+#endif
private:
tArray<T> data; // Contents of buffer...
int offset; // Position in buffer to next write.
@@ -72,26 +81,40 @@
int GetNumStored() const { return (total <= data.GetSize()) ? total : data.GetSize(); }
int GetNum() const { return total - last_total; }
- void SaveState(std::ostream& fp)
- {
- assert(fp.good());
- fp << "tBuffer" << " ";
- fp << data.GetSize() << " ";
- for (int i = 0; i < data.GetSize(); i++) fp << data[i] << " ";
- fp << offset << " " << total << " " << last_total << " " << std::endl;
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("data", data);
+ a.ArkvObj("offset", offset);
+ a.ArkvObj("total", total);
+ a.ArkvObj("last_total", last_total);
}
-
- void LoadState(std::istream& fp)
- {
- assert(fp.good());
- cString foo; fp >> foo; assert(foo == "tBuffer");
- int capacity; fp >> capacity;
- data.Resize(capacity);
- for (int i = 0; i < capacity; i++) {
- fp >> data[i];
- }
- fp >> offset >> total >> last_total;
- }
+
+ /*
+ FIXME: I'm replacing the code below with a serializing system, but
+ want to keep the old around for reference until I'm sure the new
+ system works.
+ @kgn
+ */
+ //void SaveState(std::ostream& fp)
+ //{
+ // assert(fp.good());
+ // fp << "tBuffer" << " ";
+ // fp << data.GetSize() << " ";
+ // for (int i = 0; i < data.GetSize(); i++) fp << data[i] << " ";
+ // fp << offset << " " << total << " " << last_total << " " << std::endl;
+ //}
+ //
+ //void LoadState(std::istream& fp)
+ //{
+ // assert(fp.good());
+ // cString foo; fp >> foo; assert(foo == "tBuffer");
+ // int capacity; fp >> capacity;
+ // data.Resize(capacity);
+ // for (int i = 0; i < capacity; i++) {
+ // fp >> data[i];
+ // }
+ // fp >> offset >> total >> last_total;
+ //}
};
#endif
Modified: development/source/tools/tDictionary.h
===================================================================
--- development/source/tools/tDictionary.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tDictionary.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -28,7 +28,17 @@
#include "tHashTable.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
template <class T> class tDictionary {
+#if USE_tMemTrack
+ tMemTrack<tDictionary<T> > mt;
+#endif
private:
tHashTable<cString, T> m_hash;
@@ -71,7 +81,11 @@
}
return best_match;
}
-
+
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("m_hash", m_hash);
+ }
};
#endif
Modified: development/source/tools/tHashTable.h
===================================================================
--- development/source/tools/tHashTable.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tHashTable.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -60,6 +60,13 @@
#include "tList.h"
#endif
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
+
#define HASH_TABLE_SIZE_DEFAULT 23
#define HASH_TABLE_SIZE_MEDIUM 331
#define HASH_TABLE_SIZE_LARGE 2311
@@ -68,13 +75,26 @@
template <class DATA_TYPE> class tListIterator; // aggregate
template <class HASH_TYPE, class DATA_TYPE> class tHashTable {
+#if USE_tMemTrack
+ tMemTrack<tHashTable<HASH_TYPE, DATA_TYPE> > mt;
+#endif
// We create a structure with full information about each entry stored in
// this dictionary.
template <class E_HASH_TYPE, class E_DATA_TYPE> struct tHashEntry {
+ #if USE_tMemTrack
+ tMemTrack<tHashEntry<E_HASH_TYPE, E_DATA_TYPE> > mt;
+ #endif
E_HASH_TYPE key;
int id;
E_DATA_TYPE data;
+
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("key", key);
+ a.ArkvObj("id", id);
+ a.ArkvObj("data", data);
+ }
};
private:
@@ -330,6 +350,13 @@
value_list.Insert(value_it, &cur_value);
}
}
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("entry_count", entry_count);
+ a.ArkvObj("table_size", table_size);
+ a.ArkvObj("entry_list", entry_list);
+ a.ArkvObj("cell_array", cell_array);
+ }
};
#endif
Modified: development/source/tools/tList.h
===================================================================
--- development/source/tools/tList.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tList.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -11,22 +11,39 @@
#ifndef tList_h
#define tList_h
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
+
#ifndef NULL
#define NULL 0
#endif
template <class T> class tListNode {
+#if USE_tMemTrack
+ tMemTrack<tListNode<T> > mt;
+#endif
public:
T * data;
tListNode<T> * next;
tListNode<T> * prev;
tListNode() : data(NULL), next(this), prev(this) { ; }
+
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.ArkvObj("data", data);
+ }
};
template <class T> class tList;
template <class T> class tBaseIterator {
+#if USE_tMemTrack
+ tMemTrack<tBaseIterator<T> > mt;
+#endif
friend class tList<T>;
protected:
virtual const tList<T> & GetConstList() = 0;
@@ -47,6 +64,9 @@
};
template <class T> class tListIterator : public tBaseIterator<T> {
+#if USE_tMemTrack
+ tMemTrack<tListIterator<T> > mt;
+#endif
friend class tList<T>;
private:
tList<T> & list;
@@ -80,6 +100,9 @@
};
template <class T> class tConstListIterator : public tBaseIterator<T> {
+#if USE_tMemTrack
+ tMemTrack<tConstListIterator<T> > mt;
+#endif
friend class tList<T>;
private:
const tList<T> & list;
@@ -110,6 +133,9 @@
template <class T> class tLWConstListIterator : public tBaseIterator<T>
{
+#if USE_tMemTrack
+ tMemTrack<tLWConstListIterator<T> > mt;
+#endif
friend class tList<T>;
private:
const tList<T>& list;
@@ -139,6 +165,9 @@
};
template <class T> class tList {
+#if USE_tMemTrack
+ tMemTrack<tList<T> > mt;
+#endif
friend class tBaseIterator<T>;
friend class tListIterator<T>;
friend class tConstListIterator<T>;
@@ -373,16 +402,63 @@
public:
- tList() : size(0), it_count(0) { }
+ tList() : size(0), it_count(0) { }
~tList() { Clear(); }
+
+
+ // Save to archive
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ // Save number of elements.
+ unsigned int count = size;
+ a.ArkvObj("count", count);
+ // Save elements.
+ const tListNode<T> * node = &root;
+ while(count-- > 0){
+ node = node->next;
+ a.ArkvObj("item", node);
+ }
+ }
+
+
+ // Load from archive
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ Clear();
+ // Retrieve number of elements.
+ unsigned int count;
+ a.ArkvObj("count", count);
+ // Retrieve elements.
+ while(count-- > 0){
+ tListNode<T> * new_node(0);
+ a.ArkvObj("item", new_node);
+
+ new_node->next = &root;
+ new_node->prev = root.prev;
+ root.prev->next = new_node;
+ root.prev = new_node;
+ size++;
+ }
+ }
+
+
+ // Ask archive to handle loads and saves separately
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
+
private:
- tList(tList & _list) { ; } // Never should be used...
- };
+ tList(tList & _list) { ; } // Never should be used...
+};
// This is an extended version of tList that contains extra functions to
// allow method pointer associated with the object type being listed.
template <class T> class tListPlus : public tList<T> {
+#if USE_tMemTrack
+ tMemTrack<tListPlus<T> > mt;
+#endif
private:
public:
Modified: development/source/tools/tManagedPointerArray.h
===================================================================
--- development/source/tools/tManagedPointerArray.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tManagedPointerArray.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -10,14 +10,23 @@
#ifndef tManagedPointerArray_h
#define tManagedPointerArray_h
-#include <assert.h>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef tArray_h
#include "tArray.h"
#endif
+#include <assert.h>
+
template <class T> class tManagedPointerArray
{
+#if USE_tMemTrack
+ tMemTrack<tManagedPointerArray<T> > mt;
+#endif
private:
T** m_data; // Data Elements
int m_size; // Number of Elements
@@ -165,6 +174,39 @@
{
for (int i = 0; i < m_size; i++) *m_data[i] = value;
}
+
+ // Save to archive
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ // Save number of elements.
+ unsigned int count = m_size;
+ a.ArkvObj("count", count);
+ // Save elements.
+ while(count-- > 0){
+ a.ArkvObj("item", (*this)[count]);
+ }
+ }
+
+
+ // Load from archive
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ // Retrieve number of elements.
+ unsigned int count;
+ a.ArkvObj("count", count);
+ ResizeClear(count);
+ // Retrieve elements.
+ while(count-- > 0){
+ a.ArkvObj("item", (*this)[count]);
+ }
+ }
+
+ // Ask archive to handle loads and saves separately
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
+
};
#endif
Modified: development/source/tools/tMatrix.h
===================================================================
--- development/source/tools/tMatrix.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tMatrix.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -38,17 +38,26 @@
*/
-#include <assert.h>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef tArray_h
#include "tArray.h"
#endif
+#include <assert.h>
+
/**
* This class provides a matrix template.
**/
template <class T> class tMatrix {
+#if USE_tMemTrack
+ tMemTrack<tMatrix<T> > mt;
+#endif
protected:
// Internal Variables
tArray<T> * data; // Data Elements
@@ -138,6 +147,43 @@
// Destructor
virtual ~tMatrix(){ if(data!=NULL) delete [] data; }
+
+ // Save to archive
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ // Save number of elements.
+ unsigned int rows = GetNumRows();
+ unsigned int cols = GetNumCols();
+ a.ArkvObj("rows", rows);
+ a.ArkvObj("cols", cols);
+ // Save elements.
+ while(rows-- > 0){
+ a.ArkvObj("row", (*this)[rows]);
+ }
+ }
+
+
+ // Load from archive
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ // Retrieve number of elements.
+ unsigned int rows;
+ unsigned int cols;
+ a.ArkvObj("rows", rows);
+ a.ArkvObj("cols", cols);
+ ResizeClear(rows, cols);
+ // Retrieve elements.
+ while(rows-- > 0){
+ a.ArkvObj("row", (*this)[rows]);
+ }
+ }
+
+
+ // Ask archive to handle loads and saves separately
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
};
#endif
Modified: development/source/tools/tMemTrack.h
===================================================================
--- development/source/tools/tMemTrack.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tMemTrack.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -1,46 +1,76 @@
-/*
- * tMemTrack.h
- * Avida
- *
- * Created by David on 12/7/05.
- * Copyright 2005-2006 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology
- *
- */
-
#ifndef tMemTrack_h
#define tMemTrack_h
-template <class T> class tMemTrack {
+/*
+To add memory-tracking to a class or struct cA, add a member variable of
+type tMemTrack<cA> (this incurs a one-byte overhead):
+
+class cA {
private:
- static int obj_count;
+ tMemTrack<A> mt;
public:
- // These "New" commands can only be used with no arguments.
- static T * New() {
- obj_count++;
- return new T;
- }
- static T * New(int count) {
- obj_count += count;
- return new T[count];
- }
+ ...
+};
- static void Free(T * ptr) {
- obj_count--;
- free ptr;
- }
- static void Free(T * ptr, int count) {
- obj_count -= count;
- free [] ptr;
- }
+This also works with template classes:
- // This New and Free just help keep track of things handled elsewhere...
- static void MarkNew() { obj_count++; }
- static void MarkFree() { obj_count--; }
+template <class T>
+class tA {
+private:
+ tMemTrack<tA<T> > mt;
+public:
+ ...
+};
-
- // And some methods to keep track of what's going on...
- static int GetCount() { return obj_count; }
+The number of instances of cA is returned by calling
+tMemTrack<cA>::Instances(), and the number of tA<cFoo> by
+tMemTrack<tA<cFoo> >::Instances().
+
+To prevent the 1-byte overhead, one could manually increment and
+decrement the instance count from within cA's constructors and
+destructor:
+
+struct cA {
+ cA(){ tMemTrack<cA>::Instances(1); }
+ cA(const cA &){ tMemTrack<cA>::Instances(1); }
+ ~cA(){ tMemTrack<cA>::Instances(-1); }
};
+***
+
+I like the former method, with a one-byte overhead, because it seems
+less error-prone. I've been wrapping the member variable in preprocessor
+conditionals so that I can easily turn-off memory-tracking (including the
+one-byte overhead):
+
+class cA {
+private:
+#if USE_tMemTrack
+ tMemTrack<cA> mt;
#endif
+public:
+ ...
+};
+
+***
+
+Note: I think that if we build dynamic libraries on windows for
+Avida-ED, we'll have to turn memory tracking off, because it uses a
+static variable. But it will still help in debugging.
+
+ at kgn
+*/
+
+template <class T> class tMemTrack {
+public:
+ tMemTrack(){ Instances(1); }
+ tMemTrack(const tMemTrack &){ Instances(1); }
+ ~tMemTrack(){ Instances(-1); }
+public:
+ static int Instances(int count = 0){
+ static int s_instances = 0;
+ return s_instances += count;
+ }
+};
+
+#endif
Modified: development/source/tools/tSmartArray.h
===================================================================
--- development/source/tools/tSmartArray.h 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/tools/tSmartArray.h 2006-05-01 18:17:22 UTC (rev 630)
@@ -10,12 +10,18 @@
#ifndef tSmartArray_h
#define tSmartArray_h
-#include <assert.h>
+#if USE_tMemTrack
+# ifndef tMemTrack_h
+# include "tMemTrack.h"
+# endif
+#endif
#ifndef tArray_h
#include "tArray.h"
#endif
+#include <assert.h>
+
// "I am so smart..."
static const int SMRT_INCREASE_MINIMUM = 10;
static const double SMRT_INCREASE_FACTOR = 1.5;
@@ -23,6 +29,9 @@
template <class T> class tSmartArray
{
+#if USE_tMemTrack
+ tMemTrack<tSmartArray<T> > mt;
+#endif
private:
T* m_data; // Data Array
@@ -137,6 +146,38 @@
{
for (int i = 0; i < m_active; i++) m_data[i] = value;
}
+
+ // Save to archive
+ template<class Archive>
+ void save(Archive & a, const unsigned int version) const {
+ // Save number of elements.
+ unsigned int count = m_active;
+ a.ArkvObj("count", count);
+ // Save elements.
+ while(count-- > 0){
+ a.ArkvObj("item", (*this)[count]);
+ }
+ }
+
+
+ // Load from archive
+ template<class Archive>
+ void load(Archive & a, const unsigned int version){
+ // Retrieve number of elements.
+ unsigned int count;
+ a.ArkvObj("count", count);
+ ResizeClear(count);
+ // Retrieve elements.
+ while(count-- > 0){
+ a.ArkvObj("item", (*this)[count]);
+ }
+ }
+
+ // Ask archive to handle loads and saves separately
+ template<class Archive>
+ void serialize(Archive & a, const unsigned int version){
+ a.SplitLoadSave(*this, version);
+ }
};
#endif
Modified: development/source/utils/task_events/CMakeLists.txt
===================================================================
--- development/source/utils/task_events/CMakeLists.txt 2006-04-26 19:14:41 UTC (rev 629)
+++ development/source/utils/task_events/CMakeLists.txt 2006-05-01 18:17:22 UTC (rev 630)
@@ -1,7 +1,7 @@
INCLUDE_DIRECTORIES(${ALL_INC_DIRS})
ADD_EXECUTABLE(task_event_gen task_event_gen.cc)
-TARGET_LINK_LIBRARIES(task_event_gen tools)
+TARGET_LINK_LIBRARIES(task_event_gen tools archive boost_serialization)
LINK_DIRECTORIES(${ALL_LIB_DIRS})
INSTALL_TARGETS(/work task_event_gen)
Added: development/support/utils/AvidaUtils/BoostPythonTool.py
===================================================================
--- development/support/utils/AvidaUtils/BoostPythonTool.py 2006-04-26 19:14:41 UTC (rev 629)
+++ development/support/utils/AvidaUtils/BoostPythonTool.py 2006-05-01 18:17:22 UTC (rev 630)
@@ -0,0 +1,133 @@
+##############################################################################
+## Copyright (C) 1999-2005 Michigan State University ##
+## Based on work Copyright (C) 1993-2003 California Institute of Technology ##
+## ##
+## Read the COPYING and README files, or contact 'avida at alife.org', ##
+## before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. ##
+##############################################################################
+
+"""
+BoostPythonTool
+
+Tool-specific initialization for Boost.Python.
+
+Provides builders and configuration variables for building Python
+extension modules to interface with C++ libraries.
+"""
+
+import SCons
+import os
+import re
+
+Split = SCons.Util.Split
+
+def _checkKey(env, key):
+ if env.Dictionary().has_key(key) and (None != env[key]): return env[key]
+
+def _checkKeySubst(env, key):
+ if env.Dictionary().has_key(key) and (None != env[key]): return env.subst('$%s' % key)
+
+def CheckBoostPython(context):
+ """
+ Custom test to verify Boost.Python functionality. Tries building a
+ small Boost.Python module using provided Boost.Python library, library
+ path, and include directory.
+ """
+ # FIXME: when we get the chance, write some code to verify that the
+ # built python module works. @kgn
+
+ # Try building...
+ context.Message("Checking Boost.Python ... ")
+ result = context.TryBuild(
+ context.env.BoostPythonModule,
+ """
+#include <boost/python.hpp>
+#include <boost/cstdint.hpp>
+class boost_python_conftest
+{ public: boost_python_conftest(){} };
+using namespace boost::python;
+BOOST_PYTHON_MODULE(boost_python_conftest)
+{ class_< boost_python_conftest, boost::noncopyable >("boost_python_conftest", init< >()); }
+int main(int argc, char **argv){
+ init_module_boost_python_conftest();
+ return 0;
+}
+""",
+ context.env['BOOST_PYTHON_CXX_SUFFIX']
+ )
+ context.Result(result)
+ return result
+
+def find(env):
+ boost_python_lib = _checkKeySubst(env, 'boostPythonLib')
+ boost_python_lib_dir = _checkKeySubst(env, 'boostPythonLibDir')
+ boost_include_dir = _checkKeySubst(env, 'boostIncludeDir')
+ env2 = env.Copy()
+ conf = env2.Configure(custom_tests = {'CheckBoostPython' : CheckBoostPython})
+ result = conf.CheckBoostPython()
+ conf.Finish()
+ if not result:
+ env.Append(
+ BOOST_PYTHON_TOOL_ERR = """
+BoostPythonTool error:
+ Boost.Python not functional: I tried and failed to use Boost.Python to
+ make a small Python module. Are command-line options "boostPythonLib",
+ "boostPythonLibDir", "boostIncludeDir" set correctly?
+"""
+ )
+
+
+ShCXXAction = SCons.Action.Action("$BOOST_PYTHON_SHCXXCOM", "$BOOST_PYTHON_SHCXXCOMSTR")
+LdModuleLinkAction = SCons.Action.Action("$BOOST_PYTHON_LDMODULECOM", "$BOOST_PYTHON_LDMODULECOMSTR")
+
+def generate(env):
+ """
+ Adds builders and construction variables for Boost.Python to an
+ Environment.
+ """
+ env.SetDefault(
+ BOOST_PYTHON_TOOL_ERR = '',
+ BOOST_PYTHON_CPPFLAGS = ['$PYTHON_BASECFLAGS'],
+ BOOST_PYTHON_CPPDEFINES = [],
+ BOOST_PYTHON_CPPPATH = ['$boostIncludeDir', '$PYTHON_INCLUDEPY'],
+ BOOST_PYTHON_CXX_SUFFIX = '.boost.python.cpp',
+ BOOST_PYTHON_LIBPATH = ['$boostPythonLibDir'],
+ BOOST_PYTHON_LIBS = ['$boostPythonLib'],
+ BOOST_PYTHON_SHLINK = '$PYTHON_LDSHARED',
+ BOOST_PYTHON_LDMODULE = '$BOOST_PYTHON_SHLINK',
+ BOOST_PYTHON_LDMODULEFLAGS = '',
+ _BOOST_PYTHON_CPPINCFLAGS = '$( ${_concat(INCPREFIX, BOOST_PYTHON_CPPPATH, INCSUFFIX, __env__, RDirs, TARGET)} $)',
+ _BOOST_PYTHON_CPPDEFFLAGS = '${_defines(CPPDEFPREFIX, BOOST_PYTHON_CPPDEFINES, CPPDEFSUFFIX, __env__)}',
+ _BOOST_PYTHON_LIBFLAGS = '${_stripixes(LIBLINKPREFIX, BOOST_PYTHON_LIBS, LIBLINKSUFFIX, LIBPREFIX, LIBSUFFIX, __env__)}',
+ _BOOST_PYTHON_LIBDIRFLAGS = '$( ${_concat(LIBDIRPREFIX, BOOST_PYTHON_LIBPATH, LIBDIRSUFFIX, __env__, RDirs, TARGET)} $)',
+ BOOST_PYTHON_SHCXXCOM = '$SHCXX $SHCXXFLAGS $CPPFLAGS $BOOST_PYTHON_CPPFLAGS $_CPPDEFFLAGS $_BOOST_PYTHON_CPPDEFFLAGS $_CPPINCFLAGS $_BOOST_PYTHON_CPPINCFLAGS -c -o $TARGET $SOURCES',
+ BOOST_PYTHON_LDMODULECOM = '$BOOST_PYTHON_LDMODULE $BOOST_PYTHON_LDMODULEFLAGS -o ${TARGET} $SOURCES $_LIBDIRFLAGS $_BOOST_PYTHON_LIBDIRFLAGS $_LIBFLAGS $_BOOST_PYTHON_LIBFLAGS',
+ )
+
+ boost_python_ld_module_link_action = SCons.Action.Action("$BOOST_PYTHON_LDMODULECOM", "$BOOST_PYTHON_LDMODULECOMSTR")
+ boost_python_shared_object_builder = SCons.Builder.Builder(
+ action = [ ShCXXAction ],
+ prefix = '$SHOBJPREFIX',
+ suffix = '$SHOBJSUFFIX',
+ src_suffix = '$BOOST_PYTHON_CXX_SUFFIX',
+ source_scanner = SCons.Tool.SourceFileScanner,
+ single_source = True
+ )
+ boost_python_module_builder = SCons.Builder.Builder(
+ action = [ LdModuleLinkAction ],
+ prefix = '',
+ suffix = '$PYTHON_SO',
+ target_scanner = SCons.Tool.ProgramScanner,
+ src_suffix = '$SHOBJSUFFIX',
+ src_builder = 'BoostPythonSharedObject',
+ single_source = True
+ )
+ env.AppendUnique(BUILDERS = {'BoostPythonSharedObject' : boost_python_shared_object_builder})
+ env.AppendUnique(BUILDERS = {'BoostPythonModule' : boost_python_module_builder})
+
+ if env.subst('$runConfTests') in ['yes', '1']:
+ find(env)
+
+def exists(env):
+ return find(env)
+
Modified: development/support/utils/AvidaUtils/UnitTestTool.py
===================================================================
--- development/support/utils/AvidaUtils/UnitTestTool.py 2006-04-26 19:14:41 UTC (rev 629)
+++ development/support/utils/AvidaUtils/UnitTestTool.py 2006-05-01 18:17:22 UTC (rev 630)
@@ -1,4 +1,5 @@
import SCons
+import os
def unit_test_action(target, source, env):
app = str(source[0].abspath)
More information about the Avida-cvs
mailing list