PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_geometry_type_from_string()

static void test_geometry_type_from_string ( void  )
static

Definition at line 362 of file cu_libgeom.c.

References COLLECTIONTYPE, geometry_type_from_string(), LINETYPE, LW_FAILURE, LW_SUCCESS, MULTIPOLYGONTYPE, POINTTYPE, and ovdump::type.

Referenced by libgeom_suite_setup().

363 {
364  int rv;
365  uint8_t type = 0;
366  int z = 0, m = 0;
367  char *str;
368 
369  str = " POINTZ";
370  rv = geometry_type_from_string(str, &type, &z, &m);
371  //printf("\n in type: %s\nout type: %d\n out z: %d\n out m: %d", str, type, z, m);
372  CU_ASSERT_EQUAL(rv, LW_SUCCESS);
373  CU_ASSERT_EQUAL(type, POINTTYPE);
374  CU_ASSERT_EQUAL(z, 1);
375  CU_ASSERT_EQUAL(m, 0);
376 
377  str = "LINESTRINGM ";
378  rv = geometry_type_from_string(str, &type, &z, &m);
379  //printf("\n in type: %s\nout type: %d\n out z: %d\n out m: %d", str, type, z, m);
380  CU_ASSERT_EQUAL(rv, LW_SUCCESS);
381  CU_ASSERT_EQUAL(type, LINETYPE);
382  CU_ASSERT_EQUAL(z, 0);
383  CU_ASSERT_EQUAL(m, 1);
384 
385  str = "MULTIPOLYGONZM";
386  rv = geometry_type_from_string(str, &type, &z, &m);
387  //printf("\n in type: %s\nout type: %d\n out z: %d\n out m: %d", str, type, z, m);
388  CU_ASSERT_EQUAL(rv, LW_SUCCESS);
389  CU_ASSERT_EQUAL(type, MULTIPOLYGONTYPE);
390  CU_ASSERT_EQUAL(z, 1);
391  CU_ASSERT_EQUAL(m, 1);
392 
393  str = " GEOMETRYCOLLECTIONZM ";
394  rv = geometry_type_from_string(str, &type, &z, &m);
395  //printf("\n in type: %s\nout type: %d\n out z: %d\n out m: %d", str, type, z, m);
396  CU_ASSERT_EQUAL(rv, LW_SUCCESS);
397  CU_ASSERT_EQUAL(type, COLLECTIONTYPE);
398  CU_ASSERT_EQUAL(z, 1);
399  CU_ASSERT_EQUAL(m, 1);
400 
401  str = " GEOMERYCOLLECTIONZM ";
402  rv = geometry_type_from_string(str, &type, &z, &m);
403  //printf("\n in type: %s\nout type: %d\n out z: %d\n out m: %d", str, type, z, m);
404  CU_ASSERT_EQUAL(rv, LW_FAILURE);
405 
406 }
#define LINETYPE
Definition: liblwgeom.h:86
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
Calculate type integer and dimensional flags from string input.
Definition: g_util.c:163
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define LW_FAILURE
Definition: liblwgeom.h:79
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
type
Definition: ovdump.py:41
unsigned char uint8_t
Definition: uthash.h:79
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: