From f4f4aa7dbe5e57900e3b6271bcc84732fb17583a Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 3 Mar 2010 06:06:23 +0000 Subject: [PATCH] Add some tests of the old versus new WKB output. git-svn-id: http://svn.osgeo.org/postgis/trunk@5370 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/cunit/cu_wkb.c | 31 ++++++++++++++++++++++++++----- liblwgeom/lwout_wkb.c | 2 +- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/liblwgeom/cunit/cu_wkb.c b/liblwgeom/cunit/cu_wkb.c index 98717d0c7..040bccc49 100644 --- a/liblwgeom/cunit/cu_wkb.c +++ b/liblwgeom/cunit/cu_wkb.c @@ -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){} diff --git a/liblwgeom/lwout_wkb.c b/liblwgeom/lwout_wkb.c index 2a0a54df7..0b72b7204 100644 --- a/liblwgeom/lwout_wkb.c +++ b/liblwgeom/lwout_wkb.c @@ -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); -- 2.50.1