1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 * Copyright (C) 2017 Frediano Ziglio
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20 /*
21 * Purpose: test we can declare any possible column type.
22 */
23 #include "common.h"
24 #include <assert.h>
25
test_declaration(TDSSOCKET * tds,TDSCOLUMN * curcol)26 static void test_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol)
27 {
28 char declaration[128];
29 TDSRET ret;
30
31 declaration[0] = 0;
32 ret = tds_get_column_declaration(tds, curcol, declaration);
33 assert(ret == TDS_SUCCESS);
34 printf("Declaration: %s\n", declaration);
35 assert(declaration[0] != 0);
36 }
37
38 int
main(int argc,char ** argv)39 main(int argc, char **argv)
40 {
41 int g_result = 0;
42 TDSCONTEXT *ctx;
43 TDSSOCKET *tds;
44
45 setbuf(stdout, NULL);
46 setbuf(stderr, NULL);
47
48 ctx = tds_alloc_context(NULL);
49 assert(ctx);
50 if (ctx->locale && !ctx->locale->date_fmt) {
51 /* set default in case there's no locale file */
52 ctx->locale->date_fmt = strdup(STD_DATETIME_FMT);
53 }
54
55 tds = tds_alloc_socket(ctx, 512);
56 assert(tds);
57
58 tds_all_types(tds, test_declaration);
59
60 tds_free_socket(tds);
61 tds_free_context(ctx);
62
63 return g_result;
64 }
65