SORTIE C++ Test Documentation
Classes | Public Member Functions | Protected Member Functions | List of all members
clTestTreePopulation Class Reference

Tests the clTreePopulation class. More...

#include <TestTreePopulation.h>

Inheritance diagram for clTestTreePopulation:

Classes

class  clFakeLinkedList
 This is for making a fake linked list. More...
 
struct  treeResults
 This structure is for testing tree results - arrays of this struct can tell, for a given list of trees, which should be found, and which actually were. More...
 

Public Member Functions

void TestTreePopulation ()
 Combines all the tests for testing the tree population.
 

Protected Member Functions

void TestKillTree (clSimManager *p_oSimManager)
 Tests tree killing.
 
void TestGetters (clSimManager *p_oSimManager)
 Tests tree population getter functions.
 
void TestTreeSetters (clSimManager *p_oSimManager)
 Tests the setter functions for trees, particularly error trapping.
 
void TestSnagAges (clSimManager *p_oSimManager)
 This tests the snag age updating.
 
void TestHashTable (clSimManager *p_oSimManager)
 Tests hash table loading and organization.
 
void TestHashTableNoAllomUpdate (clSimManager *p_oSimManager)
 Does the same tests as TestHashTable, but does it with no updates and no automatic allometry updating.
 
void TestTreeSearching (clSimManager *p_oSimManager)
 Tests tree searching.
 
void CheckHashTable (clTreePopulation *p_oPop, clTree ****p_oShortestHD, clTree ****p_oTallestHD, clFakeLinkedList ***p_oShort, clFakeLinkedList ***p_oTall, int iNumXCells, int iNumYCells)
 Checks the real hash table against the predicted results.
 
void LoadTrees1 (clTreePopulation *p_oPop, clTree ****p_oShortestHD, clTree ****p_oTallestHD, clFakeLinkedList ***p_oShort, clFakeLinkedList ***p_oTall, clTree **p_oTreeSet, int iNumXCells, int iNumYCells, bool bFullCheck, bool bUpdateHashTable)
 Loads the first set of trees for hash table checking.
 
void LoadTrees2 (clTreePopulation *p_oPop, clTree **p_oTreeSet, bool bFullCheck)
 Loads the first set of trees for hash table checking.
 
void EmptyFakeHashTable (clTree ****p_oShortestHD, clTree ****p_oTallestHD, clFakeLinkedList ***p_oShort, clFakeLinkedList ***p_oTall, int iNumXCells, int iNumYCells)
 Cleans up memory for CheckHashTable.
 
void DoSet1Searches (clTreePopulation *p_oPop, clTree **p_oTreeSet)
 Performs the first set of tree search tests.
 
void DoSet2Searches (clTreePopulation *p_oPop, clTree **p_oTreeSet)
 Performs the second set of tree search tests.
 
void DoSet3Searches (clTreePopulation *p_oPop)
 Performs the third set of tree search tests.
 
void CheckTreeSearch (struct treeResults *p_expected, short int iNumResults, clTreeSearch *p_oActual, clTree *p_oFirstTree)
 Checks the tree results against a list of expected results.
 
void UpdateHashTableTrees (clTreePopulation *p_oPop, clTree ****p_oShortestHD, clTree ****p_oTallestHD, clFakeLinkedList ***p_oShort, clFakeLinkedList ***p_oTall, clTree **p_oTreeSet, int iNumXCells, int iNumYCells, bool bFullCheck, bool bUpdateNow, bool bUpdateAllometry)
 Performs updates of the tree set to make sure the hash table is updated correctly.
 
void DeleteHashTableTrees (clTreePopulation *p_oPop, clTree ****p_oShortestHD, clTree ****p_oTallestHD, clFakeLinkedList ***p_oShort, clFakeLinkedList ***p_oTall, clTree **p_oTreeSet, int iNumXCells, int iNumYCells)
 Deletes the set of trees in a certain order to make sure the hash table is updated correctly.
 
const char * WriteXMLFile1 ()
 Writes a parameter file for testing.
 
const char * WriteXMLFile2 ()
 Writes a parameter file for testing.
 
const char * WriteXMLFile3 ()
 Writes a parameter file for testing.
 
const char * WriteXMLFile4 ()
 Writes a parameter file for testing.
 
const char * WriteXMLFile5 ()
 Writes a parameter file for testing.
 
const char * WriteXMLFile6 ()
 Writes a parameter file for testing distance-height tree searches on a plot which has odd-sized end grids (100X100 m plot).
 

Detailed Description

Tests the clTreePopulation class.

The test script guiding the test is Population Test.xls.

Member Function Documentation

void clTestTreePopulation::CheckHashTable ( clTreePopulation *  p_oPop,
clTree ****  p_oShortestHD,
clTree ****  p_oTallestHD,
clFakeLinkedList ***  p_oShort,
clFakeLinkedList ***  p_oTall,
int  iNumXCells,
int  iNumYCells 
)
protected

Checks the real hash table against the predicted results.

Parameters
p_oPopPointer to tree population.
p_oShortestHDShortest links
p_oTallestHDTallest links
p_oShortFake shortest hash table.
p_oTallFake tallest hash table.
iNumXCellsNumber population X cells.
iNumYCellsNumber population Y cells.
void clTestTreePopulation::CheckTreeSearch ( struct treeResults p_expected,
short int  iNumResults,
clTreeSearch *  p_oActual,
clTree *  p_oFirstTree 
)
protected

Checks the tree results against a list of expected results.

This will check for trees not found that should be found, trees that are found which should not be found, and trees found multiple times. This will also make sure that tree searches can handle continued calls to NextTree() after NULL-ing without choking. Results are directed to the log file.

Parameters
p_expectedArray of treeResults which shows expected values. There can be trees in this list that are not expected to be found.
iNumResultsNumber of elements in p_expected array.
p_oActualTree search object to test.
p_oFirstTreeThe expected first tree found.
void clTestTreePopulation::DeleteHashTableTrees ( clTreePopulation *  p_oPop,
clTree ****  p_oShortestHD,
clTree ****  p_oTallestHD,
clFakeLinkedList ***  p_oShort,
clFakeLinkedList ***  p_oTall,
clTree **  p_oTreeSet,
int  iNumXCells,
int  iNumYCells 
)
protected

Deletes the set of trees in a certain order to make sure the hash table is updated correctly.

Parameters
p_oPopPointer to tree population object
p_oShortestHDShortest links
p_oTallestHDTallest links
p_oShortFake shortest hash table.
p_oTallFake tallest hash table.
iNumXCellsNumber population X cells.
iNumYCellsNumber population Y cells.
p_oTreeSetThe set of trees
void clTestTreePopulation::DoSet1Searches ( clTreePopulation *  p_oPop,
clTree **  p_oTreeSet 
)
protected

Performs the first set of tree search tests.

void clTestTreePopulation::DoSet2Searches ( clTreePopulation *  p_oPop,
clTree **  p_oTreeSet 
)
protected

Performs the second set of tree search tests.

void clTestTreePopulation::DoSet3Searches ( clTreePopulation *  p_oPop)
protected

Performs the third set of tree search tests.

void clTestTreePopulation::EmptyFakeHashTable ( clTree ****  p_oShortestHD,
clTree ****  p_oTallestHD,
clFakeLinkedList ***  p_oShort,
clFakeLinkedList ***  p_oTall,
int  iNumXCells,
int  iNumYCells 
)
protected

Cleans up memory for CheckHashTable.

Parameters
p_oShortestHDShortest links
p_oTallestHDTallest links
p_oShortFake shortest hash table.
p_oTallFake tallest hash table.
iNumXCellsNumber population X cells.
iNumYCellsNumber population Y cells.
void clTestTreePopulation::LoadTrees1 ( clTreePopulation *  p_oPop,
clTree ****  p_oShortestHD,
clTree ****  p_oTallestHD,
clFakeLinkedList ***  p_oShort,
clFakeLinkedList ***  p_oTall,
clTree **  p_oTreeSet,
int  iNumXCells,
int  iNumYCells,
bool  bFullCheck,
bool  bUpdateHashTable 
)
protected

Loads the first set of trees for hash table checking.

Parameters
p_oPopPointer to tree population.
p_oShortestHDShortest links
p_oTallestHDTallest links
p_oShortFake shortest hash table.
p_oTallFake tallest hash table.
iNumXCellsNumber population X cells.
iNumYCellsNumber population Y cells.
p_oTreeSetThe set of trees to create
bFullCheckIf true, the function checks the hash table after each tree is created to make sure it is correct.
bUpdateHashTableIf true, this creates the fake hash table and keeps it updated.
void clTestTreePopulation::LoadTrees2 ( clTreePopulation *  p_oPop,
clTree **  p_oTreeSet,
bool  bFullCheck 
)
protected

Loads the first set of trees for hash table checking.

Parameters
p_oPopPointer to tree population.
p_oTreeSetThe set of trees to create
bFullCheckIf true, the function checks the hash table after each tree is created to make sure it is correct.
void clTestTreePopulation::TestGetters ( clSimManager *  p_oSimManager)
protected

Tests tree population getter functions.

WriteXMLFile1() is used to load a file.

Parameters
p_oSimManagerSim Manager object.
void clTestTreePopulation::TestHashTable ( clSimManager *  p_oSimManager)
protected

Tests hash table loading and organization.

Particular sets of trees are created and hard-coded into a hash table in the correct sort. This test hash table is then compared to the real hash table to see if they match. The set of trees has been chosen to test the hash table sorting as much as possible.

WriteXMLFile1() is used to load a file. This function is structured the way it is because it was ported from other code.

Parameters
p_oSimManagerSim Manager object.
void clTestTreePopulation::TestHashTableNoAllomUpdate ( clSimManager *  p_oSimManager)
protected

Does the same tests as TestHashTable, but does it with no updates and no automatic allometry updating.

WriteXMLFile1() is used to load a file. This function is structured the way it is because it was ported from other code.

Parameters
p_oSimManagerSim Manager object.
void clTestTreePopulation::TestKillTree ( clSimManager *  p_oSimManager)
protected

Tests tree killing.

To test to make sure snags are correctly created, WriteXMLFile3() is used to load a file. Seedlings, saplings, adults, and snags with all dead reasons are fed to KillTree() to make sure that the right thing happens. Then, to make sure snags aren't created when they aren't wanted, WriteXMLFile4() is used to load a file and the same thing done to the trees.

Parameters
p_oSimManagerSim Manager object.
void clTestTreePopulation::TestSnagAges ( clSimManager *  p_oSimManager)
protected

This tests the snag age updating.

It uses WriteXMLFile4() to create a run where snags are supported. Two snags are created in the file. Another is created by the function. It is verified that the ages of all are 0. Then a timestep is run, and it is verified that the ages of all snags are

  1. The process is repeated with WriteXMLFile5(), which does the same thing except with three years per timestep.
void clTestTreePopulation::TestTreePopulation ( )

Combines all the tests for testing the tree population.

void clTestTreePopulation::TestTreeSearching ( clSimManager *  p_oSimManager)
protected

Tests tree searching.

A known list of trees is loaded. Then the expected results of a search, hard-coded, are compared against the actual search returned. An array of trees has a place to count the number of trees each tree is found (this makes sure that trees are not returned multiple times). The hard-coded expected results indicates whether the tree should have been found or not. Then CheckTreeSearch validates the results of each search. WriteXMLFile2() is used to load a file. This is structured like it is because it was ported from other code.

Parameters
p_oSimManagerSim Manager object.
void clTestTreePopulation::TestTreeSetters ( clSimManager *  p_oSimManager)
protected

Tests the setter functions for trees, particularly error trapping.

Parameters
p_oSimManagerSim Manager object.
void clTestTreePopulation::UpdateHashTableTrees ( clTreePopulation *  p_oPop,
clTree ****  p_oShortestHD,
clTree ****  p_oTallestHD,
clFakeLinkedList ***  p_oShort,
clFakeLinkedList ***  p_oTall,
clTree **  p_oTreeSet,
int  iNumXCells,
int  iNumYCells,
bool  bFullCheck,
bool  bUpdateNow,
bool  bUpdateAllometry 
)
protected

Performs updates of the tree set to make sure the hash table is updated correctly.

Parameters
p_oPopPointer to tree population object
p_oShortestHDShortest links
p_oTallestHDTallest links
p_oShortFake shortest hash table.
p_oTallFake tallest hash table.
iNumXCellsNumber population X cells.
iNumYCellsNumber population Y cells.
p_oTreeSetThe set of trees to create
bFullCheckWhether to check the hash table after each update
bUpdateNowMatches the trees' bUpdateNow argument
bUpdateAllometryMatches the trees' bUpdateAllometry argument
const char* clTestTreePopulation::WriteXMLFile1 ( )
protected

Writes a parameter file for testing.

This is primarily for hash table sorting. Characteristics:

  • Three species, with various values for getting/setting.
  • Known plot lengths for pop. cell testing.
  • The only behavior does not use snags or stumps.
Returns
Filename written.
const char* clTestTreePopulation::WriteXMLFile2 ( )
protected

Writes a parameter file for testing.

This is primarily for hash table sorting. Characteristics:

  • Known plot lengths for pop. cell testing.
  • The only behavior does not use snags or stumps.
Returns
Filename written.
const char* clTestTreePopulation::WriteXMLFile3 ( )
protected

Writes a parameter file for testing.

Characteristics:

  • Two species.
  • There is no behavior which uses snags.
  • There is a behavior which uses stumps, but only for Species 1.
  • There is a tree map with seedlings, saplings, adults, and snags.
Returns
Filename written.
const char* clTestTreePopulation::WriteXMLFile4 ( )
protected

Writes a parameter file for testing.

Characteristics:

  • Two species.
  • There is a behavior which uses snags.
  • There is a behavior which uses stumps, but only for Species 1.
  • There is a tree map with seedlings, saplings, adults, and snags.
Returns
Filename written.
const char* clTestTreePopulation::WriteXMLFile5 ( )
protected

Writes a parameter file for testing.

Characteristics:

  • 3 years per timestep.
  • Two species.
  • There is a behavior which uses snags.
  • There is a behavior which uses stumps, but only for Species 1.
  • There is a tree map with seedlings, saplings, adults, and snags.
Returns
Filename written.
const char* clTestTreePopulation::WriteXMLFile6 ( )
protected

Writes a parameter file for testing distance-height tree searches on a plot which has odd-sized end grids (100X100 m plot).

Returns
Filename written.

The documentation for this class was generated from the following file: