3
check_point_to_tile_wrong_arg_type.c - Test case for GeoPackage Extensions
5
Author: Brad Hards <bradh@frogmouth.net>
7
------------------------------------------------------------------------------
9
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11
The contents of this file are subject to the Mozilla Public License Version
12
1.1 (the "License"); you may not use this file except in compliance with
13
the License. You may obtain a copy of the License at
14
http://www.mozilla.org/MPL/
16
Software distributed under the License is distributed on an "AS IS" basis,
17
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
18
for the specific language governing rights and limitations under the
21
The Original Code is GeoPackage extensions
23
The Initial Developer of the Original Code is Brad Hards
25
Portions created by the Initial Developer are Copyright (C) 2012
26
the Initial Developer. All Rights Reserved.
31
Alternatively, the contents of this file may be used under the terms of
32
either the GNU General Public License Version 2 or later (the "GPL"), or
33
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34
in which case the provisions of the GPL or the LGPL are applicable instead
35
of those above. If you wish to allow use of your version of this file only
36
under the terms of either the GPL or the LGPL, and not to allow others to
37
use your version of this file under the terms of the MPL, indicate your
38
decision by deleting the provisions above and replace them with the notice
39
and other provisions required by the GPL or the LGPL. If you do not delete
40
the provisions above, a recipient may use your version of this file under
41
the terms of any one of the MPL, the GPL or the LGPL.
50
#include <spatialite.h>
52
#include "test_helpers.h"
54
int main (int argc UNUSED, char *argv[] UNUSED)
56
sqlite3 *db_handle = NULL;
58
void *cache = spatialite_alloc_connection();
61
ret = sqlite3_open_v2 (":memory:", &db_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
62
// For debugging / testing if required
63
// ret = sqlite3_open_v2 ("check_point_to_tile_wrong_arg_type.sqlite", &db_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
64
spatialite_init_ex(db_handle, cache, 0);
65
if (ret != SQLITE_OK) {
66
fprintf (stderr, "cannot open in-memory db: %s\n", sqlite3_errmsg (db_handle));
67
sqlite3_close (db_handle);
72
/* try gpkgPointToTile with the wrong argument types */
73
ret = sqlite3_exec (db_handle, "SELECT gpkgPointToTile(1, 2, 3, 4, 5)", NULL, NULL, &err_msg);
74
if (ret != SQLITE_ERROR) {
75
fprintf(stderr, "Expected error for bad arg 1, got %i\n", ret);
76
sqlite3_free (err_msg);
79
if (strcmp(err_msg, "gpkgPointToTile() error: argument 1 [table] is not of the String type") != 0)
81
fprintf (stderr, "Unexpected error message for bad arg 1: %s\n", err_msg);
82
sqlite3_free(err_msg);
85
sqlite3_free(err_msg);
87
ret = sqlite3_exec (db_handle, "SELECT gpkgPointToTile('test1_tiles', 2.3, 3, 4, 5)", NULL, NULL, &err_msg);
88
if (ret != SQLITE_ERROR) {
89
fprintf(stderr, "Expected error for bad arg 2, got %i\n", ret);
90
sqlite3_free (err_msg);
93
if (strcmp(err_msg, "gpkgPointToTile() error: argument 2 [srid] is not of the integer type") != 0)
95
fprintf (stderr, "Unexpected error message for bad arg 2: %s\n", err_msg);
96
sqlite3_free(err_msg);
99
sqlite3_free(err_msg);
101
ret = sqlite3_exec (db_handle, "SELECT gpkgPointToTile('test1_tiles', 4326, 'hello', 4, 5)", NULL, NULL, &err_msg);
102
if (ret != SQLITE_ERROR) {
103
fprintf(stderr, "Expected error for bad arg 3, got %i\n", ret);
104
sqlite3_free (err_msg);
107
if (strcmp(err_msg, "gpkgPointToTile() error: argument 3 [x coordinate] is not of a numerical type") != 0)
109
fprintf (stderr, "Unexpected error message for bad arg 3: %s\n", err_msg);
110
sqlite3_free(err_msg);
113
sqlite3_free(err_msg);
115
ret = sqlite3_exec (db_handle, "SELECT gpkgPointToTile('test1_tiles', 4326, 3.2, 'bye', 5)", NULL, NULL, &err_msg);
116
if (ret != SQLITE_ERROR) {
117
fprintf(stderr, "Expected error for bad arg 4, got %i\n", ret);
118
sqlite3_free (err_msg);
121
if (strcmp(err_msg, "gpkgPointToTile() error: argument 4 [y coordinate] is not of a numerical type") != 0)
123
fprintf (stderr, "Unexpected error message for bad arg 4: %s\n", err_msg);
124
sqlite3_free(err_msg);
127
sqlite3_free(err_msg);
129
ret = sqlite3_exec (db_handle, "SELECT gpkgPointToTile('test1_tiles', 4326, 3.2, 5.2, 1.9)", NULL, NULL, &err_msg);
130
if (ret != SQLITE_ERROR) {
131
fprintf(stderr, "Expected error for bad arg 5, got %i\n", ret);
132
sqlite3_free (err_msg);
135
if (strcmp(err_msg, "gpkgPointToTile() error: argument 5 [zoom level] is not of the integer type") != 0)
137
fprintf (stderr, "Unexpected error message for bad arg 5: %s\n", err_msg);
138
sqlite3_free(err_msg);
141
sqlite3_free(err_msg);
143
ret = sqlite3_close (db_handle);
144
if (ret != SQLITE_OK) {
145
fprintf (stderr, "sqlite3_close() error: %s\n", sqlite3_errmsg (db_handle));
149
spatialite_cleanup_ex(cache);