[QGIS Commit] r9400 - in trunk/external_plugins/cdp2/src: lib tests

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Sep 24 05:13:30 EDT 2008


Author: timlinux
Date: 2008-09-24 05:13:29 -0400 (Wed, 24 Sep 2008)
New Revision: 9400

Modified:
   trunk/external_plugins/cdp2/src/lib/filewriter.cpp
   trunk/external_plugins/cdp2/src/tests/cdptest.cpp
Log:
Additional test implementation

Modified: trunk/external_plugins/cdp2/src/lib/filewriter.cpp
===================================================================
--- trunk/external_plugins/cdp2/src/lib/filewriter.cpp	2008-09-24 08:54:34 UTC (rev 9399)
+++ trunk/external_plugins/cdp2/src/lib/filewriter.cpp	2008-09-24 09:13:29 UTC (rev 9400)
@@ -77,9 +77,9 @@
   // 1) if you send mInputNoData out the output stream, it truncates it to -9999
   // 2) if gdal reads -9999 as the first cell, it assumes dataset is int 16, causeing all values
   //    thereafter to be read as int16, losing any data after the decimal place
-  // 3) using a decimal place wich isnt well represented by float32 will cause problems.
+  // 3) using a decimal place which isnt well represented by float32 will cause problems.
   //    we initially used -9999.99 as no data, but when gdal reads this from the asc file again
-  //    it incorrectly receivese the value of -9999.8998433943 or similar. THis causes all the
+  //    it incorrectly receives the value of -9999.8998433943 or similar. THis causes all the
   //    stats for the file to be incorrect. So now we use -9999.5 as default
   // 4) in dataprocessor, comparisons of no data are made between the input file data (which is -9999 usually)
   //    and the data processords idea of what no data shoud be. Consequently we need to rewrite nodata now.

Modified: trunk/external_plugins/cdp2/src/tests/cdptest.cpp
===================================================================
--- trunk/external_plugins/cdp2/src/tests/cdptest.cpp	2008-09-24 08:54:34 UTC (rev 9399)
+++ trunk/external_plugins/cdp2/src/tests/cdptest.cpp	2008-09-24 09:13:29 UTC (rev 9400)
@@ -26,15 +26,20 @@
 {
   Q_OBJECT;
   private slots:
-  /** Regression test for making sure 
-      available calcs always computes correctly grid layers */
-  void availableCalcsTest(); 
+  void runTest(); 
   void initTestCase();// will be called before the first testfunction is executed.
   void cleanupTestCase();// will be called after the last testfunction was executed.
   void init(){};// will be called before each testfunction is executed.
   void cleanup(){};// will be called after every testfunction.
   private:
   //add private test vars here
+  QString mMeanTempFile;
+  QString mMinTempFile;
+  QString mMaxTempFile;
+  QString mDiurnalTempFile;
+  QString mSolarRadFile;
+  QString mMeanPrecipFile;
+  QString mFrostDaysFile;
 };
 
 void CdpTest::initTestCase()
@@ -42,12 +47,53 @@
   QCoreApplication::setOrganizationName("Linfiniti Consulting");
   QCoreApplication::setOrganizationDomain("linfiniti.com");
   QCoreApplication::setApplicationName("ClimateDataProcessor");
+  QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
+  mMeanTempFile = myFileName + QDir::separator() + "meantemp01.asc";
+  mMinTempFile = myFileName + QDir::separator() + "mintemp01.asc";
+  mMaxTempFile = myFileName + QDir::separator() + "maxtemp01.asc";
+  mDiurnalTempFile = myFileName + QDir::separator() + "diurnaltemp01.asc";
+  mSolarRadFile = myFileName + QDir::separator() + "solarrad01.asc";
+  mMeanPrecipFile = myFileName + QDir::separator() + "meanprecip01.asc";
+  mFrostDaysFile = myFileName + QDir::separator() + "frostdays01.asc";
 }
+
 void CdpTest::cleanupTestCase()
 {
 }
-void CdpTest::availableCalcsTest()
+void CdpTest::runTest()
 {
+  ClimateDataProcessorController myController;
+  myController.setMeanTempFileName(mMeanTempFile);
+  myController.setMinTempFileName(mMinTempFile);
+  myController.setMaxTempFileName(mMaxTempFile);
+  myController.setDiurnalTempFileName(mDiurnalTempFile);
+  myController.setMeanPrecipFileName(mMeanPrecipFile);
+  myController.setTotalSolarRadFileName(mSolarRadFile);
+  myController.setFrostDaysFileName(mFrostDaysFile);
+
+  myController.setOutputPath( QDir::tempPath() );
+
+  //specify which of the available calcs we want to actually do
+  if (! myController.makeAvailableCalculationsMap() )
+  {
+    QFAIL ("Error making available calcs map");
+  }
+  QMap<QString, bool> myMap = myController.availableCalculationsMap();
+  QMapIterator<QString, bool> myMapIterator(myMap);
+  while (myMapIterator.hasNext())
+  {
+    myMapIterator.next();
+    QString myKey = myMapIterator.key();
+    myController.addUserCalculation(myKey);
+  }
+  // Show a summary of the controller state (for debug purposes only)  
+  qDebug(myController.description().toLocal8Bit());
+  if (! myController.makeFileGroups() )
+  {
+    QFAIL ("Failed to make file groups");
+  }
+  myController.run();
+
 }
 
 QTEST_MAIN(CdpTest) 



More information about the QGIS-commit mailing list