# Object files
OBJS= \
cu_pgsql2shp.o \
+ cu_shp2pgsql.o \
cu_tester.o
LOADER_OBJS= \
../getopt.o \
../shpcommon.o \
../safileio.o \
- ../pgsql2shp-core.o
+ ../pgsql2shp-core.o \
+ ../shp2pgsql-core.o
# We test this variable later to see if we're building the GUI
gtk_build = @GTK_BUILD@
void test_ShpDumperCreate(void);
void test_ShpDumperDestroy(void);
-SHPDUMPERCONFIG *config;
-SHPDUMPERSTATE *state;
+SHPDUMPERCONFIG *dumper_config;
+SHPDUMPERSTATE *dumper_state;
/*
** Called from test harness to register the tests in this file.
void test_ShpDumperCreate(void)
{
- config = (SHPDUMPERCONFIG*)calloc(1, sizeof(SHPDUMPERCONFIG));
- set_config_defaults(config);
- state = ShpDumperCreate(config);
- CU_ASSERT_PTR_NOT_NULL(state);
- CU_ASSERT_EQUAL(state->config->fetchsize, 100);
+ dumper_config = (SHPDUMPERCONFIG*)calloc(1, sizeof(SHPDUMPERCONFIG));
+ set_dumper_config_defaults(dumper_config);
+ dumper_state = ShpDumperCreate(dumper_config);
+ CU_ASSERT_PTR_NOT_NULL(dumper_state);
+ CU_ASSERT_EQUAL(dumper_state->config->fetchsize, 100);
}
void test_ShpDumperDestroy(void)
{
- ShpDumperDestroy(state);
+ ShpDumperDestroy(dumper_state);
}
--- /dev/null
+/**********************************************************************
+ * $Id: cu_shp2pgsql.c 5674 2010-06-03 02:04:15Z mleslie $
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2010 LISAsoft Pty Ltd
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ *
+ **********************************************************************/
+
+#include "cu_shp2pgsql.h"
+#include "cu_tester.h"
+#include "../shp2pgsql-core.h"
+
+/* Test functions */
+void test_ShpLoaderCreate(void);
+void test_ShpLoaderDestroy(void);
+
+SHPLOADERCONFIG *loader_config;
+SHPLOADERSTATE *loader_state;
+
+/*
+** Called from test harness to register the tests in this file.
+*/
+CU_pSuite register_shp2pgsql_suite(void)
+{
+ CU_pSuite pSuite;
+ pSuite = CU_add_suite("Shapefile Loader File shp2pgsql Test", init_shp2pgsql_suite, clean_shp2pgsql_suite);
+ if (NULL == pSuite)
+ {
+ CU_cleanup_registry();
+ return NULL;
+ }
+
+ if (
+ (NULL == CU_add_test(pSuite, "test_ShpLoaderCreate()", test_ShpLoaderCreate)) ||
+ (NULL == CU_add_test(pSuite, "test_ShpLoaderDestroy()", test_ShpLoaderDestroy))
+ )
+ {
+ CU_cleanup_registry();
+ return NULL;
+ }
+ return pSuite;
+}
+
+/*
+** The suite initialization function.
+** Create any re-used objects.
+*/
+int init_shp2pgsql_suite(void)
+{
+ return 0;
+}
+
+/*
+** The suite cleanup function.
+** Frees any global objects.
+*/
+int clean_shp2pgsql_suite(void)
+{
+ return 0;
+}
+
+void test_ShpLoaderCreate(void)
+{
+ loader_config = (SHPLOADERCONFIG*)calloc(1, sizeof(SHPLOADERCONFIG));
+ set_loader_config_defaults(loader_config);
+ loader_state = ShpLoaderCreate(loader_config);
+ CU_ASSERT_PTR_NOT_NULL(loader_state);
+ CU_ASSERT_STRING_EQUAL(loader_state->config->encoding, ENCODING_DEFAULT);
+}
+
+void test_ShpLoaderDestroy(void)
+{
+ ShpLoaderDestroy(loader_state);
+}
--- /dev/null
+/**********************************************************************
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2010 LISAsoft Pty Ltd
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ *
+ **********************************************************************/
+
+#ifndef __cu_shp2pgsql_h__
+#define __cu_shp2pgsql_h__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
+
+/***********************************************************************
+** for Computational Geometry Suite
+*/
+
+/* Admin functions */
+int init_shp2pgsql_suite(void);
+int clean_shp2pgsql_suite(void);
+
+#endif /* __cu_shp2pgsql_h__ */
return CU_get_error();
}
#endif
-
+
+ /* Add the shp2pgsql test suite */
+ if (NULL == register_shp2pgsql_suite())
+ {
+ CU_cleanup_registry();
+ return CU_get_error();
+ }
+
/* Add the pgsql2shp test suite */
if (NULL == register_pgsql2shp_suite())
{
#define __cu_tester_h__
CU_pSuite register_list_suite(void);
+CU_pSuite register_shp2pgsql_suite(void);
CU_pSuite register_pgsql2shp_suite(void);
#endif /* __cu_tester_h__ */
/* Parse command line options and set configuration */
config = malloc(sizeof(SHPDUMPERCONFIG));
- set_config_defaults(config);
+ set_dumper_config_defaults(config);
while ((c = pgis_getopt(argc, argv, "bf:h:du:p:P:g:rkm:")) != EOF)
{
char *convert_bytes_to_hex(uchar *ewkb, size_t size);
-/* liblwgeom allocator callback - install the defaults (malloc/free/stdout/stderr) */
-void lwgeom_init_allocators()
-{
- lwgeom_install_default_allocators();
-}
-
-
static SHPObject *
create_point(SHPDUMPERSTATE *state, LWPOINT *lwpoint)
{
/* Default configuration settings */
void
-set_config_defaults(SHPDUMPERCONFIG *config)
+set_dumper_config_defaults(SHPDUMPERCONFIG *config)
{
config->conn = malloc(sizeof(SHPCONNECTIONCONFIG));
config->conn->host = NULL;
/* Externally accessible functions */
-void set_config_defaults(SHPDUMPERCONFIG *config);
+void set_dumper_config_defaults(SHPDUMPERCONFIG *config);
char *shapetypename(int num);
SHPDUMPERSTATE *ShpDumperCreate(SHPDUMPERCONFIG *config);
/* Parse command line options and set configuration */
config = malloc(sizeof(SHPLOADERCONFIG));
- set_config_defaults(config);
+ set_loader_config_defaults(config);
/* Keep the flag list alphabetic so it's easy to see what's left. */
while ((c = pgis_getopt(argc, argv, "acdeg:iknpr:s:wDGIN:ST:W:X:")) != EOF)
} Ring;
-/* liblwgeom allocator callback - install the defaults (malloc/free/stdout/stderr) */
-void lwgeom_init_allocators()
-{
- lwgeom_install_default_allocators();
-}
-
-
/*
* Internal functions
*/
/* Default configuration settings */
void
-set_config_defaults(SHPLOADERCONFIG *config)
+set_loader_config_defaults(SHPLOADERCONFIG *config)
{
config->opt = 'c';
config->table = NULL;
/* Externally accessible functions */
void strtolower(char *s);
void vasbappend(stringbuffer_t *sb, char *fmt, ... );
-void set_config_defaults(SHPLOADERCONFIG *config);
+void set_loader_config_defaults(SHPLOADERCONFIG *config);
SHPLOADERSTATE *ShpLoaderCreate(SHPLOADERCONFIG *config);
int ShpLoaderOpenShape(SHPLOADERSTATE *state);
/* Parse command line options and set configuration */
config = malloc(sizeof(SHPLOADERCONFIG));
- set_config_defaults(config);
+ set_loader_config_defaults(config);
/* Here we override any defaults for the GUI */
config->createindex = 1;
#include <stdlib.h>
#include "shpcommon.h"
+
+/* liblwgeom allocator callback - install the defaults (malloc/free/stdout/stderr) */
+void lwgeom_init_allocators()
+{
+ lwgeom_install_default_allocators();
+}
+
+
/**
* Escape strings that are to be used as part of a PostgreSQL connection string. If no
* characters require escaping, simply return the input pointer. Otherwise return a