[QGIS Commit] r9238 - trunk/qgis/tests/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Sep 1 13:47:46 EDT 2008


Author: ersts
Date: 2008-09-01 13:47:46 -0400 (Mon, 01 Sep 2008)
New Revision: 9238

Modified:
   trunk/qgis/tests/src/core/testcontrastenhancements.cpp
Log:
-Updated Contrast Enhancement test

Modified: trunk/qgis/tests/src/core/testcontrastenhancements.cpp
===================================================================
--- trunk/qgis/tests/src/core/testcontrastenhancements.cpp	2008-09-01 17:14:59 UTC (rev 9237)
+++ trunk/qgis/tests/src/core/testcontrastenhancements.cpp	2008-09-01 17:47:46 UTC (rev 9238)
@@ -23,6 +23,7 @@
 #include <qgscliptominmaxenhancement.h>
 #include <qgscontrastenhancement.h>
 #include <qgslinearminmaxenhancement.h>
+#include <qgslinearminmaxenhancementwithclip.h>
 
 /** \ingroup UnitTests
  * This is a unit test for the ContrastEnhancements contrast enhancement classes.
@@ -36,7 +37,8 @@
     void init() {};// will be called before each testfunction is executed.
     void cleanup() {};// will be called after every testfunction.
 
-    void minMaxEnhancementTest();
+    void clipMinMaxEnhancementTest();
+    void linearMinMaxEnhancementWithClipTest();
     void linearMinMaxEnhancementTest();
   private:
     QString mReport;
@@ -63,20 +65,42 @@
 }
 
 
-void TestContrastEnhancements::minMaxEnhancementTest()
+void TestContrastEnhancements::clipMinMaxEnhancementTest()
 {
+  //Clips 0 < x < 10, 240 < X < 256
+  //Stretch no stretch is applied
   QgsClipToMinMaxEnhancement myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
+  // Original pixel value 0.0 Should be out of range thus clipped
   QVERIFY(!myEnhancement.isValueInDisplayableRange(0.0));
-  QVERIFY(10.0 == myEnhancement.enhanceValue(0.0)) ; 
-  QVERIFY(250.0 == myEnhancement.enhanceValue(240.0)) ; 
+  //Original pixel value of 10.0 should be scaled to 10.0
+  QVERIFY(10.0 == myEnhancement.enhanceValue(10.0)) ;
+  //Original pixel value of 240 should be scaled to 240 
+  QVERIFY(240.0 == myEnhancement.enhanceValue(240.0)) ; 
 }
+
+void TestContrastEnhancements::linearMinMaxEnhancementWithClipTest()
+{
+  //First clips 0 < x < 10, 240 < X < 256
+  //Then stretch 10 = 0, 240 = 255 linearly distribute values 10 -> 240 between 0 -> 255
+  QgsLinearMinMaxEnhancementWithClip myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
+  // Original pixel value 0.0 Should be out of range thus clipped
+  QVERIFY(!myEnhancement.isValueInDisplayableRange(0.0));
+  //Original pixel value of 10.0 should be scaled to 0.0
+  QVERIFY(0.0 == myEnhancement.enhanceValue(10.0)) ;
+  //Original pixel value of 240 should be scaled to 255 
+  QVERIFY(255.0 == myEnhancement.enhanceValue(240.0)) ;
+}
+
 void TestContrastEnhancements::linearMinMaxEnhancementTest()
 {
+  //Stretch 10 = 0, 240 = 255 linearly distribute values 10 -> 240 between 0 -> 255
   QgsLinearMinMaxEnhancement myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
   //0 should be scaled to 10 and not clipped
   QVERIFY(myEnhancement.isValueInDisplayableRange(0.0));
-  QVERIFY(10.0 == myEnhancement.enhanceValue(0.0)) ; 
-  QVERIFY(250.0 == myEnhancement.enhanceValue(240.0)) ; 
+  //Original pixel value of 10.0 should be scaled to 0.0
+  QVERIFY(0.0 == myEnhancement.enhanceValue(10.0)) ;
+  //Original pixel value of 240 should be scaled to 255 
+  QVERIFY(255.0 == myEnhancement.enhanceValue(240.0)) ;
 }
 QTEST_MAIN( TestContrastEnhancements )
 #include "moc_testcontrastenhancements.cxx"



More information about the QGIS-commit mailing list