14 #include "CUnit/Basic.h"
61 int main(
int argc,
char *argv[])
65 CU_pSuite suite_to_run;
68 CU_ErrorCode errCode = 0;
69 CU_pTestRegistry registry;
87 if (CUE_SUCCESS != CU_initialize_registry())
89 errCode = CU_get_error();
90 printf(
" Error attempting to initialize registry: %d. See CUError.h for error code list.\n", errCode);
102 CU_basic_set_mode(CU_BRM_VERBOSE);
105 errCode = CU_basic_run_tests();
112 registry = CU_get_registry();
113 for (index = 1; index < argc; index++)
115 suite_name = argv[index];
117 suite_to_run = CU_get_suite_by_name(suite_name, registry);
118 if (NULL == suite_to_run)
121 suite_to_run = registry->pSuite;
122 while (suite_to_run != NULL)
124 test_to_run = CU_get_test_by_name(suite_name, suite_to_run);
125 if (test_to_run != NULL)
128 test_name = suite_name;
129 suite_name = suite_to_run->pName;
132 suite_to_run = suite_to_run->pNext;
135 if (suite_to_run == NULL)
137 printf(
"\n'%s' does not appear to be either a suite name or a test name.\n\n", suite_name);
141 if (test_name != NULL)
144 printf(
"\nRunning test '%s' in suite '%s'.\n", test_name, suite_name);
148 errCode = CU_run_test(suite_to_run, test_to_run);
149 if (errCode != CUE_SUCCESS)
151 printf(
" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
155 num_run = CU_get_number_of_asserts();
156 num_failed = CU_get_number_of_failures();
157 printf(
"\n %s - asserts - %3d passed, %3d failed, %3d total.\n\n",
158 (0 == num_failed ?
"PASSED" :
"FAILED"), (num_run - num_failed), num_failed, num_run);
164 printf(
"\nRunning all tests in suite '%s'.\n", suite_name);
168 errCode = CU_run_suite(suite_to_run);
169 if (errCode != CUE_SUCCESS)
171 printf(
" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
175 num_run = CU_get_number_of_tests_run();
176 num_failed = CU_get_number_of_tests_failed();
177 printf(
"\n %s - tests - %3d passed, %3d failed, %3d total.\n",
178 (0 == num_failed ?
"PASSED" :
"FAILED"), (num_run - num_failed), num_failed, num_run);
179 num_run = CU_get_number_of_asserts();
180 num_failed = CU_get_number_of_failures();
181 printf(
" - asserts - %3d passed, %3d failed, %3d total.\n\n",
182 (num_run - num_failed), num_failed, num_run);
188 CU_basic_show_failures(CU_get_failure_list());
191 num_failed = CU_get_number_of_failures();
192 CU_cleanup_registry();
215 for (i = 0; i < nbands; ++i) {
237 CU_ASSERT(mem != NULL);
240 memset(mem, nodataval, datasize);
242 memset(mem, 0, datasize);
245 CU_ASSERT(
band != NULL);
249 CU_ASSERT(bandNum >= 0);
#define MAX_CUNIT_MSG_LENGTH
void(* PG_SuiteSetup)(void)
void(*) typedef void(*) voi lwgeom_set_handlers)(lwallocator allocator, lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter, lwreporter noticereporter)
Install custom memory management and error handling functions you want your application to use.
rt_band rt_band_new_inline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t *data)
Create an in-db rt_band with no data.
void * default_rt_allocator(size_t size)
The default memory/logging handlers installed by lwgeom_install_default_allocators()
void rt_band_set_ownsdata_flag(rt_band band, int flag)
void * rtalloc(size_t size)
Wrappers used for managing memory.
int rt_raster_add_band(rt_raster raster, rt_band band, int index)
Add band data to a raster.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
void default_rt_deallocator(void *mem)
void rt_band_destroy(rt_band band)
Destroy a raster band.
uint16_t rt_raster_get_num_bands(rt_raster raster)
uint16_t rt_raster_get_height(rt_raster raster)
uint16_t rt_raster_get_width(rt_raster raster)
void default_rt_warning_handler(const char *fmt, va_list ap)
void default_rt_info_handler(const char *fmt, va_list ap)
void * default_rt_reallocator(void *mem, size_t size)
void rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator, rt_deallocator deallocator, rt_message_handler error_handler, rt_message_handler info_handler, rt_message_handler warning_handler)
This function is called when the PostgreSQL backend is taking care of the memory and we want to use p...
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
void raster_wkb_suite_setup(void)
int main(int argc, char *argv[])
void band_basics_suite_setup(void)
void raster_basics_suite_setup(void)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)
void pixtype_suite_setup(void)
void misc_suite_setup(void)
void cu_error_msg_reset()
PG_SuiteSetup setupfuncs[]
void mapalgebra_suite_setup(void)
char cu_error_msg[MAX_CUNIT_MSG_LENGTH+1]
void gdal_suite_setup(void)
void band_stats_suite_setup(void)
void spatial_relationship_suite_setup(void)
void band_misc_suite_setup(void)
void raster_misc_suite_setup(void)
static void cu_error_reporter(const char *fmt, va_list ap)
CUnit error handler Log message in a global var instead of printing in stderr.
void raster_geometry_suite_setup(void)