[Avida-SVN] r1128 - in extras: . source/testsuites
avidaedward at myxo.css.msu.edu
avidaedward at myxo.css.msu.edu
Mon Dec 11 19:35:55 PST 2006
Author: avidaedward
Date: 2006-12-11 22:35:55 -0500 (Mon, 11 Dec 2006)
New Revision: 1128
Added:
extras/source/testsuites/nAnalyze.cpp
Modified:
extras/
extras/SConscript
Log:
r1101 at Kaben-Nanlohys-MacBook-Pro-15: kaben | 2006-11-22 12:55:09 -0500
* Added testsuite for cAnalyze.
- I haven't yet verified that it runs.
Property changes on: extras
___________________________________________________________________
Name: svk:merge
+ 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/extras:1101
Modified: extras/SConscript
===================================================================
--- extras/SConscript 2006-12-12 03:29:32 UTC (rev 1127)
+++ extras/SConscript 2006-12-12 03:35:55 UTC (rev 1128)
@@ -108,6 +108,7 @@
# Library of test suites.
testsuites_srcs = [
+ 'source/testsuites/nAnalyze.cpp',
'source/testsuites/nChangeList.cpp',
'source/testsuites/nDataEntry.cpp',
'source/testsuites/nDataFile.cpp',
Added: extras/source/testsuites/nAnalyze.cpp
===================================================================
--- extras/source/testsuites/nAnalyze.cpp 2006-12-12 03:29:32 UTC (rev 1127)
+++ extras/source/testsuites/nAnalyze.cpp 2006-12-12 03:35:55 UTC (rev 1128)
@@ -0,0 +1,82 @@
+
+#include "cAnalyze.h"
+
+#include "cFile.h"
+#include "cTestLib.h"
+#include "cXMLArchive.h"
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+/* Tests. */
+namespace nAnalyze {
+ /* Test-helpers. */
+ template <class T>
+ void save_stuff(const T &s, const char * filename){
+ std::ofstream ofs(filename);
+ cXMLOArchive oa(ofs);
+ oa.ArkvObj("cAnalyze_Archive", s);
+ }
+
+ template <class T>
+ void restore_stuff(T &s, const char * filename) {
+ std::ifstream ifs(filename);
+ cXMLIArchive ia(ifs);
+ ia.ArkvObj("cAnalyze_Archive", s);
+ }
+
+ /* Unit tests. */
+ namespace UnitTest_HelloWorld {
+ void test(const cStringList &attrs){
+ if(!attrs.HasString("HelloWorld")){
+ cout << "XXX Skipping HelloWorld test." << endl;
+ return;
+ }
+ cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+ /* Make sure testing is working with successes and failures. @kgn */
+ TEST(true);
+ TEST(false);
+ }
+ cAddTestSuite t("cAnalyze_UnitTest_HelloWorld", test);
+ }
+
+ namespace UnitTest_Archiving {
+ void test(const cStringList &attrs){
+ if(!attrs.HasString("Template")){
+ cout << "XXX Skipping Template test." << endl;
+ return;
+ }
+# if !ENABLE_SERIALIZATION
+ cout << "XXX : Test skipped because serialization is disabled." << endl;
+# else // ENABLE_SERIALIZATION
+ cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+ //std::string filename("./cAnalyze_basic_serialization.xml");
+
+ //{
+ // cAnalyze o();
+ // save_stuff<>(o, filename.c_str());
+ //}
+
+ //{
+ // cAnalyze o;
+
+ // restore_stuff<>(o, filename.c_str());
+ // TEST(true);
+ //}
+
+ //std::remove(filename.c_str());
+# endif // ENABLE_SERIALIZATION
+ }
+ cAddTestSuite t("cAnalyze_UnitTest_Archiving", test);
+ }
+
+ /*
+ This function does nothing;
+ but if the compiler sees that this function is called, then the
+ compiler will also connect the above tests to the testing library.
+ */
+ void PhysicalLink(){}
+}
+
+
More information about the Avida-cvs
mailing list