]> granicus.if.org Git - postgis/commitdiff
Add some tests of the old versus new WKB output.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 3 Mar 2010 06:06:23 +0000 (06:06 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 3 Mar 2010 06:06:23 +0000 (06:06 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5370 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_wkb.c
liblwgeom/lwout_wkb.c

index 98717d0c71888b529fdc94cede6a1462d959d8b8..040bccc492ab7a5837d538c3f4ca378ec500915b 100644 (file)
@@ -22,6 +22,7 @@
 ** Global variable to hold WKB strings
 */
 char *s;
+char *t;
 
 /*
 ** The suite initialization function.
@@ -30,6 +31,7 @@ char *s;
 static int init_wkb_suite(void)
 {
        s = NULL;
+       t = NULL;
        return 0;
 }
 
@@ -39,23 +41,42 @@ static int init_wkb_suite(void)
 */
 static int clean_wkb_suite(void)
 {
-       free(s);
+       if (s) free(s);
+       if (t) free(t);
        s = NULL;
+       t = NULL;
        return 0;
 }
 
-static char* cu_wkb(char *wkt, uchar variant)
+static void cu_wkb(char *wkt)
 {
        LWGEOM *g = lwgeom_from_ewkt(wkt, PARSER_CHECK_NONE);
        if ( s ) free(s);
-       s = lwgeom_to_wkb(g, variant | WKB_HEX, NULL);  
+       if ( t ) free(t);
+       s = lwgeom_to_wkb(g, WKB_HEX | WKB_NDR | WKB_EXTENDED, NULL);   
+       t = lwgeom_to_hexwkb(g, PARSER_CHECK_NONE, NDR);
        lwgeom_free(g);
-       return s;
 }
 
 static void test_wkb_point(void)
 {
-       //printf("%s\n", cu_wkb("POINT(0 0 0 0)", WKB_ISO ));
+       cu_wkb("POINT(0 0 0 0)");
+       CU_ASSERT_STRING_EQUAL(s, t);
+
+       cu_wkb("LINESTRING(0 0,1 1)");
+       CU_ASSERT_STRING_EQUAL(s, t);
+
+       cu_wkb("SRID=4;POLYGON((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0))");
+       CU_ASSERT_STRING_EQUAL(s, t);
+
+       cu_wkb("SRID=14;GEOMETRYCOLLECTION(POLYGON((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),POINT(1 1 1))");
+       CU_ASSERT_STRING_EQUAL(s, t);
+
+       cu_wkb("SRID=14;MULTIPOLYGON(((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((-1 -1 0,-1 2 0,2 2 0,2 -1 0,-1 -1 0),(0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)))");
+       CU_ASSERT_STRING_EQUAL(s, t);
+
+//     printf("new: %s\nold: %s\n",s,t);
+
 }
 
 static void test_wkb_linestring(void){}
index 2a0a54df7a3bd3c283254b5359c2ba1756bf4af2..0b72b720440ef620c2f08b479cb8a6d844fb0abb 100644 (file)
@@ -151,7 +151,7 @@ static char* int32_to_wkb_buf(const int ival, char *buf, uchar variant)
        {
                lwerror("Machine int size is not %d bytes!", WKB_INT_SIZE);
        }
-       LWDEBUGF(4, "Writing value '%d'", ival);
+       LWDEBUGF(4, "Writing value '%u'", ival);
        if( variant & WKB_HEX )
        {
                int swap =  wkb_swap_bytes(variant);