PostGIS  2.5.0dev-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 1168 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().

1169 {
1170  uint32_t i;
1171 
1172  char *ewkt[] =
1173  {
1174  "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1175  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1176  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1177  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
1178  };
1179 
1180  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1181  {
1182  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1183  GBOX box;
1184  gbox_init(&box);
1185  lwgeom_drop_bbox(geom);
1186 
1187  /* Construct a GSERIALIZED* that doesn't have a box, so that we can test the
1188  * actual logic of the peek function */
1189  size_t expected_size = gserialized_from_lwgeom_size(geom);
1190  GSERIALIZED* gser = lwalloc(expected_size);
1191  uint8_t* ptr = (uint8_t*) gser;
1192 
1193  ptr += 8; // Skip header
1194  gserialized_from_lwgeom_any(geom, ptr);
1195  gser->flags = geom->flags;
1196 
1197  CU_ASSERT_FALSE(gserialized_has_bbox(gser));
1198  CU_ASSERT_EQUAL(LW_FAILURE, gserialized_peek_gbox_p(gser, &box));
1199 
1200  lwgeom_free(geom);
1201  lwfree(gser);
1202  }
1203 }
void lwfree(void *mem)
Definition: lwutil.c:244
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: g_serialized.c:460
uint8_t flags
Definition: liblwgeom.h:399
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
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:673
#define LW_FAILURE
Definition: liblwgeom.h:78
unsigned int uint32_t
Definition: uthash.h:78
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:47
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:807
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:385
Here is the call graph for this function:
Here is the caller graph for this function: