[postgis-commits] svn - r3669 - spike/wktraster/rt_core

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Fri Feb 6 05:20:49 PST 2009


Author: strk
Date: 2009-02-06 05:20:48 -0800 (Fri, 06 Feb 2009)
New Revision: 3669

Modified:
   spike/wktraster/rt_core/rt_api.c
   spike/wktraster/rt_core/testapi.c
Log:
Reduce noise derived by testing out of value range errors, add test for out of dimension range errors


Modified: spike/wktraster/rt_core/rt_api.c
===================================================================
--- spike/wktraster/rt_core/rt_api.c	2009-02-06 13:12:10 UTC (rev 3668)
+++ spike/wktraster/rt_core/rt_api.c	2009-02-06 13:20:48 UTC (rev 3669)
@@ -528,7 +528,7 @@
     {
 #ifdef RT_WARN_ON_TRUNCATION
         ctx->warn("Nodata value for %s band got truncated"
-                  " from %g to %g\n",
+                  " from %g to %g",
                   rt_pixtype_name(ctx, pixtype),
                   val, band->nodataval);
 #endif

Modified: spike/wktraster/rt_core/testapi.c
===================================================================
--- spike/wktraster/rt_core/testapi.c	2009-02-06 13:12:10 UTC (rev 3668)
+++ spike/wktraster/rt_core/testapi.c	2009-02-06 13:20:48 UTC (rev 3669)
@@ -46,39 +46,44 @@
 
 static void testBand1BB(rt_context ctx, rt_band band)
 {
-    rt_band_set_nodata(ctx, band, 1);
+    int failure;
+
+    failure = rt_band_set_nodata(ctx, band, 1);
+    CHECK(!failure);
     //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
     CHECK_EQUALS(rt_band_get_nodata(ctx, band), 1);
 
-    rt_band_set_nodata(ctx, band, 0);
+    failure = rt_band_set_nodata(ctx, band, 0);
+    CHECK(!failure);
     //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
     CHECK_EQUALS(rt_band_get_nodata(ctx, band), 0);
 
-    rt_band_set_nodata(ctx, band, 2);
-    //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
-    CHECK_EQUALS(rt_band_get_nodata(ctx, band), 0);
+    failure = rt_band_set_nodata(ctx, band, 2);
+    CHECK(failure); /* out of range value */
 
-    rt_band_set_nodata(ctx, band, 3);
-    //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
-    CHECK_EQUALS(rt_band_get_nodata(ctx, band), 1);
+    failure = rt_band_set_nodata(ctx, band, 3);
+    CHECK(failure); /* out of range value */
 
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 2);
+    CHECK(failure); /* out of range value */
+
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 3);
+    CHECK(failure); /* out of range value */
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
         {
             for (y=0; y<rt_band_get_height(ctx, band); ++y)
             {
-    rt_band_set_pixel(ctx, band, x, y, 1);
+    failure = rt_band_set_pixel(ctx, band, x, y, 1);
+    CHECK(!failure);
     CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 1);
 
-    rt_band_set_pixel(ctx, band, x, y, 0);
+    failure = rt_band_set_pixel(ctx, band, x, y, 0);
+    CHECK(!failure);
     CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 0);
 
-    rt_band_set_pixel(ctx, band, x, y, 2);
-    CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 0);
-
-    rt_band_set_pixel(ctx, band, x, y, 3);
-    CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 1);
             }
         }
     }
@@ -116,6 +121,13 @@
     failure = rt_band_set_nodata(ctx, band, 5); /* invalid: out of range */
     CHECK(failure);
 
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 4); /* out of range */
+    CHECK(failure);
+
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 5); /* out of range */
+    CHECK(failure);
+
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -137,12 +149,6 @@
     CHECK_EQUALS(val, 3);
     CHECK(!failure);
 
-    failure = rt_band_set_pixel(ctx, band, x, y, 4); /* out of range */
-    CHECK(failure);
-
-    failure = rt_band_set_pixel(ctx, band, x, y, 5); /* out of range */
-    CHECK(failure);
-
             }
         }
     }
@@ -190,6 +196,10 @@
     failure = rt_band_set_nodata(ctx, band, 17);  /* out of value range */
     CHECK(failure);
 
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 35); /* out of value range */
+    CHECK(failure);
+
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -216,9 +226,6 @@
     val =  rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 15);
 
-    failure = rt_band_set_pixel(ctx, band, x, y, 35); /* out of value range */
-    CHECK(failure);
-
             }
         }
     }
@@ -273,6 +280,9 @@
     failure = rt_band_set_nodata(ctx, band, 256); /* out of value range */
     CHECK(failure);
 
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 256); /* out of value range */
+    CHECK(failure);
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -289,9 +299,6 @@
     val = rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 255);
 
-    failure = rt_band_set_pixel(ctx, band, x, y, 256); /* out of value range */
-    CHECK(failure);
-
     failure = rt_band_set_pixel(ctx, band, x, y, 1);
     CHECK(!failure);
     val = rt_band_get_pixel(ctx, band, x, y);
@@ -359,6 +366,15 @@
     failure = rt_band_set_nodata(ctx, band, 129);  
     CHECK(failure);
 
+    /* out of range (-127..127) */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, -129);  
+    CHECK(failure);
+
+    /* out of range (-127..127) */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 129);  
+    CHECK(failure);
+
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -385,14 +401,6 @@
     val = rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 127);
 
-    /* out of range (-127..127) */
-    failure = rt_band_set_pixel(ctx, band, x, y, -129);  
-    CHECK(failure);
-
-    /* out of range (-127..127) */
-    failure = rt_band_set_pixel(ctx, band, x, y, 129);  
-    CHECK(failure);
-
             }
         }
     }
@@ -432,6 +440,14 @@
     failure = rt_band_set_nodata(ctx, band, 65536); /* out of range */
     CHECK(failure);
 
+    /* out of value range */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 65536);
+    CHECK(failure);
+
+    /* out of dimensions range */
+    failure = rt_band_set_pixel(ctx, band, rt_band_get_width(ctx, band), 0, 0);
+    CHECK(failure);
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -448,9 +464,6 @@
     val = rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 65535);
 
-    failure = rt_band_set_pixel(ctx, band, x, y, 65536); /* out of range */
-    CHECK(failure);
-
             }
         }
     }
@@ -501,6 +514,18 @@
     failure = rt_band_set_nodata(ctx, band, 32769);
     CHECK(failure);
 
+    /* out of range (-32767..32767) */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, -32769); 
+    CHECK(failure);
+
+    /* out of range (-32767..32767) */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 32769); 
+    CHECK(failure);
+
+    /* out of dimensions range */
+    failure = rt_band_set_pixel(ctx, band, rt_band_get_width(ctx, band), 0, 0); 
+    CHECK(failure);
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -522,14 +547,6 @@
     val = rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 32767);
 
-    /* out of range (-32767..32767) */
-    failure = rt_band_set_pixel(ctx, band, x, y, -32769); 
-    CHECK(failure);
-
-    /* out of range (-32767..32767) */
-    failure = rt_band_set_pixel(ctx, band, x, y, 32769); 
-    CHECK(failure);
-
             }
         }
     }
@@ -564,6 +581,15 @@
     failure = rt_band_set_nodata(ctx, band, 4294967296);
     CHECK(failure);
 
+    /* out of value range */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 4294967296);
+    CHECK(failure);
+
+    /* out of dimensions range */
+    failure = rt_band_set_pixel(ctx, band, rt_band_get_width(ctx, band),
+        0, 4294967296);
+    CHECK(failure);
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -590,10 +616,6 @@
     val = rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 4294967295);
 
-    /* out of range */
-    failure = rt_band_set_pixel(ctx, band, x, y, 4294967296);
-    CHECK(failure);
-
             }
         }
     }
@@ -629,6 +651,15 @@
     /* out of range */
     CHECK(failure);
 
+    /* out of value range */
+    failure = rt_band_set_pixel(ctx, band, 0, 0, 2147483648);  
+    CHECK(failure);
+
+    /* out of dimensions range */
+    failure = rt_band_set_pixel(ctx, band, rt_band_get_width(ctx, band), 0, 0);
+    CHECK(failure);
+
+
     {
         int x, y;
         for (x=0; x<rt_band_get_width(ctx, band); ++x)
@@ -655,10 +686,6 @@
     val = rt_band_get_pixel(ctx, band, x, y);
     CHECK_EQUALS(val, 2147483647);
 
-    /* out of range */
-    failure = rt_band_set_pixel(ctx, band, x, y, 2147483648);  
-    CHECK(failure);
-
             }
         }
     }



More information about the postgis-commits mailing list