[Avida-SVN] r1130 - in extras: . source/testsuites

avidaedward at myxo.css.msu.edu avidaedward at myxo.css.msu.edu
Mon Dec 11 19:35:59 PST 2006


Author: avidaedward
Date: 2006-12-11 22:35:59 -0500 (Mon, 11 Dec 2006)
New Revision: 1130

Added:
   extras/source/testsuites/nBlah.cpp
Modified:
   extras/
   extras/source/testsuites/nAnalyze.cpp
Log:
 r1120 at Kaben-Nanlohys-MacBook-Pro-15:  kaben | 2006-12-06 11:46:25 -0500
 
 Add temporary c++ file for purpose of trying to debug scons (goddammit).
 



Property changes on: extras
___________________________________________________________________
Name: svk:merge
   - 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/extras:1102
   + 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/extras:1120

Modified: extras/source/testsuites/nAnalyze.cpp
===================================================================
--- extras/source/testsuites/nAnalyze.cpp	2006-12-12 03:35:56 UTC (rev 1129)
+++ extras/source/testsuites/nAnalyze.cpp	2006-12-12 03:35:59 UTC (rev 1130)
@@ -1,9 +1,14 @@
 
 #include "cAnalyze.h"
 
-#include "cFile.h"
+#include "cAvidaConfig.h"
+#include "cDefaultAnalyzeDriver.h"
+#include "cDefaultRunDriver.h"
+#include "cDrivermanager.h"
 #include "cTestLib.h"
 #include "cXMLArchive.h"
+#include "cWorld.h"
+
 #include <iostream>
 #include <fstream>
 
@@ -44,10 +49,134 @@
     cAddTestSuite t("cAnalyze_Brainstorm_HelloWorld", test);
   }
 
+  /* cAnalyze_Brainstorm_RunningAnalyze {{{2 */
+  namespace Brainstorm_RunningAnalyze {
+    void test(){
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+      
+      char * argv[] = {
+        "cAnalyze_Brainstorm_RunningAnalyze",
+      };
+      int argc = sizeof(argv)/sizeof(char *);
+
+      cDriverManager::Initialize();
+      cWorld *world = new cWorld(
+        cAvidaConfig::LoadWithCmdLineArgs(argc, argv)
+      );
+      cAvidaDriver* driver = new cDefaultAnalyzeDriver(
+        world,
+        (world->GetConfig().ANALYZE_MODE.Get() == 2)
+      );
+
+      driver->Run();
+
+      delete driver;
+      delete world;
+    }
+    cAddTestSuite t("cAnalyze_Brainstorm_RunningAnalyze", test);
+  }
+
   /* cAnalyze_Brainstorm_CumulativeStemminess {{{2 */
   namespace Brainstorm_CumulativeStemminess {
     void test(){
       cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+
+      /*
+      Initialize
+      */
+      cWorld world();
+
+      
+      //cAnalyzeGenotype * genotype = NULL;
+      //tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+      //const int num_gens = batch[cur_batch].List().GetSize();
+      //
+      //// Put all of the genotypes in an array for easy reference and collect
+      //// other information on them as we process them.
+      //tArray<cAnalyzeGenotype *> gen_array(num_gens);
+      //tHashTable<int, int> id_hash;  // Store array pos for each id.
+      //tArray<int> id_array(num_gens), pid_array(num_gens);
+      //tArray<int> depth_array(num_gens), birth_array(num_gens);
+      //int array_pos = 0;
+      //while ((genotype = batch_it.Next()) != NULL) {
+      //  // Put the genotype in an array.
+      //  gen_array[array_pos] = genotype;
+      //  id_hash.Add(genotype->GetID(), array_pos);
+      //  id_array[array_pos] = genotype->GetID();
+      //  pid_array[array_pos] = genotype->GetParentID();
+      //  depth_array[array_pos] = genotype->GetDepth();
+      //  birth_array[array_pos] = genotype->GetUpdateBorn();
+      //  array_pos++;
+      //}
+
+      //// Now collect information about the offspring of each individual.
+      //tArray<int> ppos_array(num_gens), offspring_count(num_gens);
+      //offspring_count.SetAll(0);
+      //for (int pos = 0; pos < num_gens; pos++) {
+      //  int parent_id = gen_array[pos]->GetParentID();
+      //  if (parent_id == -1) {  // Organism has no parent (i.e., ancestor)
+      //    ppos_array[pos] = -1;
+      //    continue;
+      //  }
+      //  int parent_pos = -1;
+      //  id_hash.Find(parent_id, parent_pos);
+      //  ppos_array[pos] = parent_pos;
+      //  offspring_count[parent_pos]++;
+      //}
+
+      //// For each genotype, figure out how far back you need to go to get to a
+      //// branch point.
+      //tArray<int> branch_dist_array(num_gens);
+      //tArray<int> branch_pos_array(num_gens);
+      //branch_dist_array.SetAll(-1);
+      //branch_pos_array.SetAll(-1);
+      //bool found = true;
+      //int loop_count = 0;
+      //while (found == true) {
+      //  found = false;
+      //  for (int pos = 0; pos < num_gens; pos++) {
+      //    if (branch_dist_array[pos] > -1) continue; // continue if its set.
+      //    found = true;
+      //    int parent_pos = ppos_array[pos];
+      //    if (parent_pos == -1) branch_dist_array[pos] = 0;  // Org is root.
+      //    else if (offspring_count[parent_pos] > 1) {        // Parent is branch.
+	    //branch_dist_array[pos] = 1;
+	    //branch_pos_array[pos] = parent_pos;
+      //    }
+      //    else if (branch_dist_array[parent_pos] > -1) {     // Parent calculated.
+	    //branch_dist_array[pos] = branch_dist_array[parent_pos]+1;
+	    //branch_pos_array[pos] = branch_pos_array[parent_pos];
+      //    }
+      //    // Otherwise, we are not yet ready to calculate this entry.
+      //  }
+      //  loop_count++;
+      //}
+
+      //
+      //// Cumulative Stemminess
+      //for (int pos = 0; pos < num_gens; pos++) {
+      //  // We're only interested in internal n-furcating nodes.
+      //  if (pid_array[pos] == -1) continue;  // Don't want root.
+      //  if (offspring_count[pos] <= 1) continue; // No leaves or nonfurcating nodes
+
+      //  // @CAO Find distance to all children.
+      //  // @CAO Find distance to parent branch.
+      //  // @CAO DO math.
+      //}
+
+
+      //cout << "LOOP COUNT:" << loop_count << endl;
+      //for (int i = 0; i < num_gens; i++) {
+      //  int branch_pos = branch_pos_array[i];
+      //  int branch_id = (branch_pos == -1) ? -1 : id_array[branch_pos];
+      //  cout << i << " "
+	    // << id_array[i] << " "
+	    // << offspring_count[i] << " "
+	    // << branch_dist_array[i] << " "
+	    // << branch_id << " "
+	    // << endl;
+      //}
+
       /* Make sure testing is working with successes and failures. @kgn */
       TEST(true);
       TEST(false);
@@ -71,6 +200,55 @@
     cAddTestSuite t("cAnalyze_UnitTest_HelloWorld", test);
   }
 
+  /* cAnalyze_UnitTest_cAvidaConfigDestruction {{{2 */
+  namespace UnitTest_cAvidaConfigDestruction {
+    void test(const cStringList &attrs){
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+      /* Make sure testing is working with successes and failures. @kgn */
+
+      cAvidaConfig* cfg = new cAvidaConfig();
+      delete cfg;
+    }
+    cAddTestSuite t("cAnalyze_UnitTest_cAvidaConfigDestruction", test);
+  }
+
+  /* cAnalyze_UnitTest_Destructor {{{2 */
+  namespace UnitTest_Destructor {
+    void test(){
+      cout << "FIXME : interim test. I'm trying to track-down" << endl;
+      cout << "bad destruction of cWorld. When I figure out" << endl;
+      cout << "what's wrong, move this test to reflect the" << endl;
+      cout << "source of the bug. @kgn" << endl;
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+
+      char * argv[] = {
+        "cAnalyze_Brainstorm_RunningAnalyze",
+        "-c", "gcs_avida.cfg",
+      };
+      int argc = sizeof(argv)/sizeof(char *);
+
+      cout << "argc : " << argc << endl;
+
+      cDriverManager::Initialize();
+      cWorld *world = new cWorld(
+        cAvidaConfig::LoadWithCmdLineArgs(argc, argv)
+      );
+      cAvidaDriver* driver = NULL;
+
+      if (world->GetConfig().ANALYZE_MODE.Get() > 0) {
+        driver = new cDefaultAnalyzeDriver(world, (world->GetConfig().ANALYZE_MODE.Get() == 2));
+      } else {
+        driver = new cDefaultRunDriver(world);
+      }
+  
+      driver->Run();
+
+      delete driver;
+      delete world;
+    }
+    cAddTestSuite t("cAnalyze_UnitTest_Destructor", test);
+  }
+
   /* cAnalyze_UnitTest_Archiving {{{2 */
   namespace UnitTest_Archiving {
     void test(const cStringList &attrs){

Added: extras/source/testsuites/nBlah.cpp
===================================================================
--- extras/source/testsuites/nBlah.cpp	2006-12-12 03:35:56 UTC (rev 1129)
+++ extras/source/testsuites/nBlah.cpp	2006-12-12 03:35:59 UTC (rev 1130)
@@ -0,0 +1,291 @@
+#include "cAnalyze.h"
+
+#include "cAvidaConfig.h"
+#include "cDefaultAnalyzeDriver.h"
+#include "cDefaultRunDriver.h"
+#include "cDrivermanager.h"
+#include "cTestLib.h"
+#include "cXMLArchive.h"
+#include "cWorld.h"
+
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+/* Tests. */
+namespace nAnalyze {
+/* Test-helpers. {{{1 */
+  /* save_stuff {{{2 */
+  template <class T>
+  void save_stuff(const T &s, const char * filename){
+    std::ofstream ofs(filename);
+    cXMLOArchive oa(ofs);
+    oa.ArkvObj("cAnalyze_Archive", s);
+  }
+
+  /* restore_stuff {{{2 */
+  template <class T>
+  void restore_stuff(T &s, const char * filename) {
+    std::ifstream ifs(filename);
+    cXMLIArchive ia(ifs);
+    ia.ArkvObj("cAnalyze_Archive", s);
+  }
+
+/* Brainstorms. {{{1 */
+  /* cAnalyze_Brainstorm_HelloWorld {{{2 */
+  namespace Brainstorm_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_Brainstorm_HelloWorld", test);
+  }
+
+  /* cAnalyze_Brainstorm_RunningAnalyze {{{2 */
+  namespace Brainstorm_RunningAnalyze {
+    void test(){
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+      
+      char * argv[] = {
+        "cAnalyze_Brainstorm_RunningAnalyze",
+      };
+      int argc = sizeof(argv)/sizeof(char *);
+
+      cDriverManager::Initialize();
+      cWorld *world = new cWorld(
+        cAvidaConfig::LoadWithCmdLineArgs(argc, argv)
+      );
+      cAvidaDriver* driver = new cDefaultAnalyzeDriver(
+        world,
+        (world->GetConfig().ANALYZE_MODE.Get() == 2)
+      );
+
+      driver->Run();
+
+      delete driver;
+      delete world;
+    }
+    cAddTestSuite t("cAnalyze_Brainstorm_RunningAnalyze", test);
+  }
+
+  /* cAnalyze_Brainstorm_CumulativeStemminess {{{2 */
+  namespace Brainstorm_CumulativeStemminess {
+    void test(){
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+
+      /*
+      Initialize
+      */
+      cWorld world();
+
+      
+      //cAnalyzeGenotype * genotype = NULL;
+      //tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+      //const int num_gens = batch[cur_batch].List().GetSize();
+      //
+      //// Put all of the genotypes in an array for easy reference and collect
+      //// other information on them as we process them.
+      //tArray<cAnalyzeGenotype *> gen_array(num_gens);
+      //tHashTable<int, int> id_hash;  // Store array pos for each id.
+      //tArray<int> id_array(num_gens), pid_array(num_gens);
+      //tArray<int> depth_array(num_gens), birth_array(num_gens);
+      //int array_pos = 0;
+      //while ((genotype = batch_it.Next()) != NULL) {
+      //  // Put the genotype in an array.
+      //  gen_array[array_pos] = genotype;
+      //  id_hash.Add(genotype->GetID(), array_pos);
+      //  id_array[array_pos] = genotype->GetID();
+      //  pid_array[array_pos] = genotype->GetParentID();
+      //  depth_array[array_pos] = genotype->GetDepth();
+      //  birth_array[array_pos] = genotype->GetUpdateBorn();
+      //  array_pos++;
+      //}
+
+      //// Now collect information about the offspring of each individual.
+      //tArray<int> ppos_array(num_gens), offspring_count(num_gens);
+      //offspring_count.SetAll(0);
+      //for (int pos = 0; pos < num_gens; pos++) {
+      //  int parent_id = gen_array[pos]->GetParentID();
+      //  if (parent_id == -1) {  // Organism has no parent (i.e., ancestor)
+      //    ppos_array[pos] = -1;
+      //    continue;
+      //  }
+      //  int parent_pos = -1;
+      //  id_hash.Find(parent_id, parent_pos);
+      //  ppos_array[pos] = parent_pos;
+      //  offspring_count[parent_pos]++;
+      //}
+
+      //// For each genotype, figure out how far back you need to go to get to a
+      //// branch point.
+      //tArray<int> branch_dist_array(num_gens);
+      //tArray<int> branch_pos_array(num_gens);
+      //branch_dist_array.SetAll(-1);
+      //branch_pos_array.SetAll(-1);
+      //bool found = true;
+      //int loop_count = 0;
+      //while (found == true) {
+      //  found = false;
+      //  for (int pos = 0; pos < num_gens; pos++) {
+      //    if (branch_dist_array[pos] > -1) continue; // continue if its set.
+      //    found = true;
+      //    int parent_pos = ppos_array[pos];
+      //    if (parent_pos == -1) branch_dist_array[pos] = 0;  // Org is root.
+      //    else if (offspring_count[parent_pos] > 1) {        // Parent is branch.
+	    //branch_dist_array[pos] = 1;
+	    //branch_pos_array[pos] = parent_pos;
+      //    }
+      //    else if (branch_dist_array[parent_pos] > -1) {     // Parent calculated.
+	    //branch_dist_array[pos] = branch_dist_array[parent_pos]+1;
+	    //branch_pos_array[pos] = branch_pos_array[parent_pos];
+      //    }
+      //    // Otherwise, we are not yet ready to calculate this entry.
+      //  }
+      //  loop_count++;
+      //}
+
+      //
+      //// Cumulative Stemminess
+      //for (int pos = 0; pos < num_gens; pos++) {
+      //  // We're only interested in internal n-furcating nodes.
+      //  if (pid_array[pos] == -1) continue;  // Don't want root.
+      //  if (offspring_count[pos] <= 1) continue; // No leaves or nonfurcating nodes
+
+      //  // @CAO Find distance to all children.
+      //  // @CAO Find distance to parent branch.
+      //  // @CAO DO math.
+      //}
+
+
+      //cout << "LOOP COUNT:" << loop_count << endl;
+      //for (int i = 0; i < num_gens; i++) {
+      //  int branch_pos = branch_pos_array[i];
+      //  int branch_id = (branch_pos == -1) ? -1 : id_array[branch_pos];
+      //  cout << i << " "
+	    // << id_array[i] << " "
+	    // << offspring_count[i] << " "
+	    // << branch_dist_array[i] << " "
+	    // << branch_id << " "
+	    // << endl;
+      //}
+
+      /* Make sure testing is working with successes and failures. @kgn */
+      TEST(true);
+      TEST(false);
+    }
+    cAddTestSuite t("cAnalyze_Brainstorm_CumulativeStemminess", test);
+  }
+
+/* Unit tests. {{{1 */
+  /* cAnalyze_UnitTest_HelloWorld {{{2 */
+  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);
+  }
+
+  /* cAnalyze_UnitTest_cAvidaConfigDestruction {{{2 */
+  namespace UnitTest_cAvidaConfigDestruction {
+    void test(const cStringList &attrs){
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+      /* Make sure testing is working with successes and failures. @kgn */
+
+      cAvidaConfig* cfg = new cAvidaConfig();
+      delete cfg;
+    }
+    cAddTestSuite t("cAnalyze_UnitTest_cAvidaConfigDestruction", test);
+  }
+
+  /* cAnalyze_UnitTest_Destructor {{{2 */
+  namespace UnitTest_Destructor {
+    void test(){
+      cout << "FIXME : interim test. I'm trying to track-down" << endl;
+      cout << "bad destruction of cWorld. When I figure out" << endl;
+      cout << "what's wrong, move this test to reflect the" << endl;
+      cout << "source of the bug. @kgn" << endl;
+      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
+
+      char * argv[] = {
+        "cAnalyze_Brainstorm_RunningAnalyze",
+        "-c", "gcs_avida.cfg",
+      };
+      int argc = sizeof(argv)/sizeof(char *);
+
+      cout << "argc : " << argc << endl;
+
+      cDriverManager::Initialize();
+      cWorld *world = new cWorld(
+        cAvidaConfig::LoadWithCmdLineArgs(argc, argv)
+      );
+      cAvidaDriver* driver = NULL;
+
+      if (world->GetConfig().ANALYZE_MODE.Get() > 0) {
+        driver = new cDefaultAnalyzeDriver(world, (world->GetConfig().ANALYZE_MODE.Get() == 2));
+      } else {
+        driver = new cDefaultRunDriver(world);
+      }
+  
+      driver->Run();
+
+      delete driver;
+      delete world;
+    }
+    cAddTestSuite t("cAnalyze_UnitTest_Destructor", test);
+  }
+
+  /* cAnalyze_UnitTest_Archiving {{{2 */
+  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);
+  }
+
+  // }}}1
+  /*
+  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