PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_gserialized_is_empty()

static void test_gserialized_is_empty ( void  )
static

Definition at line 320 of file cu_libgeom.c.

321 {
322  int i = 0;
323  struct gserialized_empty_cases {
324  const char* wkt;
325  int isempty;
326  };
327 
328  struct gserialized_empty_cases cases[] = {
329  { "POINT EMPTY", 1 },
330  { "POINT(1 1)", 0 },
331  { "LINESTRING EMPTY", 1 },
332  { "MULTILINESTRING EMPTY", 1 },
333  { "MULTILINESTRING(EMPTY)", 1 },
334  { "MULTILINESTRING(EMPTY,EMPTY)", 1 },
335  { "MULTILINESTRING(EMPTY,(0 0,1 1))", 0 },
336  { "MULTILINESTRING((0 0,1 1),EMPTY)", 0 },
337  { "MULTILINESTRING(EMPTY,(0 0,1 1),EMPTY)", 0 },
338  { "MULTILINESTRING(EMPTY,EMPTY,EMPTY)", 1 },
339  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY,EMPTY))", 1 },
340  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY),POINT(1 1))", 0 },
341  { "GEOMETRYCOLLECTION(POINT EMPTY,MULTILINESTRING(EMPTY, (0 0)),POINT EMPTY)", 0 },
342  { "GEOMETRYCOLLECTION(POLYGON EMPTY,POINT EMPTY,MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
343  { "GEOMETRYCOLLECTION(POLYGON EMPTY,GEOMETRYCOLLECTION(POINT EMPTY),MULTILINESTRING(EMPTY,EMPTY),POINT EMPTY)", 1 },
344  { NULL, 0 }
345  };
346 
347  while( cases[i].wkt )
348  {
349  // i = 11;
350  LWGEOM *lw = lwgeom_from_wkt(cases[i].wkt, LW_PARSER_CHECK_NONE);
352  int ie = gserialized_is_empty(g);
353  // printf("%s: we say %d, they say %d\n", cases[i].wkt, cases[i].isempty, ie);
354  CU_ASSERT_EQUAL(ie, cases[i].isempty);
355  lwgeom_free(lw);
356  lwfree(g);
357  i++;
358  }
359 }
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:179
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
void lwfree(void *mem)
Definition: lwutil.c:244
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904

References gserialized_from_lwgeom(), gserialized_is_empty(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by libgeom_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: