PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ test_optionlist()

static void test_optionlist ( void  )
static

Definition at line 268 of file liblwgeom/cunit/cu_misc.c.

269 {
270  size_t sz;
271  const char* value;
272  // zero out all the pointers so our list ends up null-terminated
273  char *olist[OPTION_LIST_SIZE];
274  char input[128];
275  memset(olist, 0, sizeof(olist));
276  // input string needs to be writeable because we are inserting nulls
277  strcpy(input, "key1=value1 key2=value2 ");
278  option_list_parse(input, olist);
279 
280  value = option_list_search(olist, "key1");
281  // printf("value: %s\n", value);
282  CU_ASSERT_STRING_EQUAL("value1", value);
283  value = option_list_search(olist, "key2");
284  CU_ASSERT_STRING_EQUAL("value2", value);
285  value = option_list_search(olist, "key3");
286  CU_ASSERT_EQUAL(NULL, value);
287 
288  sz = option_list_length(olist);
289  CU_ASSERT_EQUAL(4, sz);
290 
291  memset(olist, 0, sizeof(olist));
292  strcpy(input, " ");
293  option_list_parse(input, olist);
294  value = option_list_search(olist, "key1");
295  CU_ASSERT_EQUAL(NULL, value);
296 
297  memset(olist, 0, sizeof(olist));
298  strcpy(input, " key3= ");
299  option_list_parse(input, olist);
300  sz = option_list_length(olist);
301  CU_ASSERT_EQUAL(2, sz);
302 
303  strcpy(input, " key1=value1 key2='value2 value3' ");
304  memset(olist, 0, sizeof(olist));
305  option_list_gdal_parse(input, olist);
306  sz = option_list_length(olist);
307  CU_ASSERT_EQUAL(2, sz);
308  CU_ASSERT_STRING_EQUAL("key1=value1", olist[0]);
309  CU_ASSERT_STRING_EQUAL("key2='value2 value3'", olist[1]);
310 }
int value
Definition: genraster.py:62
void option_list_gdal_parse(char *input, char **olist)
Definition: optionlist.c:121
size_t option_list_length(char **olist)
Returns the total number of keys and values in the list.
Definition: optionlist.c:73
const char * option_list_search(char **olist, const char *key)
Returns null if the key cannot be found.
Definition: optionlist.c:54
void option_list_parse(char *input, char **olist)
option_list is a null-terminated list of strings, where every odd string is a key and every even stri...
Definition: optionlist.c:86
#define OPTION_LIST_SIZE
Definition: optionlist.h:31

References option_list_gdal_parse(), option_list_length(), option_list_parse(), option_list_search(), OPTION_LIST_SIZE, and genraster::value.

Referenced by misc_suite_setup().

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