PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_gserialized_peek_gbox_p_fails_for_unsupported_cases()

void test_gserialized_peek_gbox_p_fails_for_unsupported_cases ( void  )

Definition at line 1188 of file cu_libgeom.c.

References GSERIALIZED::flags, LWGEOM::flags, gbox_init(), gserialized_from_lwgeom_any(), gserialized_from_lwgeom_size(), gserialized_has_bbox(), gserialized_peek_gbox_p(), LW_FAILURE, LW_PARSER_CHECK_NONE, lwalloc(), lwfree(), lwgeom_drop_bbox(), lwgeom_free(), lwgeom_from_wkt(), and test_signum_macro().

Referenced by libgeom_suite_setup(), and test_gserialized_peek_gbox_p_gets_correct_box().

1189 {
1190  uint32_t i;
1191 
1192  char *ewkt[] =
1193  {
1194  "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1195  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1196  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1197  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
1198  };
1199 
1200  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1201  {
1202  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1203  GBOX box;
1204  gbox_init(&box);
1205  lwgeom_drop_bbox(geom);
1206 
1207  /* Construct a GSERIALIZED* that doesn't have a box, so that we can test the
1208  * actual logic of the peek function */
1209  size_t expected_size = gserialized_from_lwgeom_size(geom);
1210  GSERIALIZED* gser = lwalloc(expected_size);
1211  uint8_t* ptr = (uint8_t*) gser;
1212 
1213  ptr += 8; // Skip header
1214  gserialized_from_lwgeom_any(geom, ptr);
1215  gser->flags = geom->flags;
1216 
1217  CU_ASSERT_FALSE(gserialized_has_bbox(gser));
1218  CU_ASSERT_EQUAL(LW_FAILURE, gserialized_peek_gbox_p(gser, &box));
1219 
1220  lwgeom_free(geom);
1221  lwfree(gser);
1222  }
1223 }
void lwfree(void *mem)
Definition: lwutil.c:244
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: g_serialized.c:463
uint8_t flags
Definition: liblwgeom.h:397
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:40
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:635
#define LW_FAILURE
Definition: liblwgeom.h:79
unsigned int uint32_t
Definition: uthash.h:78
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:51
size_t gserialized_from_lwgeom_size(const LWGEOM *geom)
Calculate required memory segment to contain a serialized form of the LWGEOM.
Definition: g_serialized.c:810
static size_t gserialized_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
void * lwalloc(size_t size)
Definition: lwutil.c:229
unsigned char uint8_t
Definition: uthash.h:79
uint8_t flags
Definition: liblwgeom.h:383
Here is the call graph for this function:
Here is the caller graph for this function: