Line data Source code
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 :
26 968 : static void test_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol)
27 : {
28 : char declaration[128];
29 : TDSRET ret;
30 :
31 968 : declaration[0] = 0;
32 968 : ret = tds_get_column_declaration(tds, curcol, declaration);
33 968 : assert(ret == TDS_SUCCESS);
34 968 : printf("Declaration: %s\n", declaration);
35 968 : assert(declaration[0] != 0);
36 968 : }
37 :
38 : int
39 8 : main(void)
40 : {
41 8 : int g_result = 0;
42 : TDSCONTEXT *ctx;
43 : TDSSOCKET *tds;
44 :
45 8 : setbuf(stdout, NULL);
46 8 : setbuf(stderr, NULL);
47 :
48 8 : ctx = tds_alloc_context(NULL);
49 8 : assert(ctx);
50 8 : if (!ctx->locale->datetime_fmt) {
51 : /* set default in case there's no locale file */
52 0 : ctx->locale->datetime_fmt = strdup(STD_DATETIME_FMT);
53 : }
54 8 : free(ctx->locale->date_fmt);
55 8 : ctx->locale->date_fmt = strdup("%Y-%m-%d");
56 8 : free(ctx->locale->time_fmt);
57 8 : ctx->locale->time_fmt = strdup("%H:%M:%S");
58 :
59 8 : tds = tds_alloc_socket(ctx, 512);
60 8 : assert(tds);
61 :
62 8 : tds_all_types(tds, test_declaration);
63 :
64 8 : tds_free_socket(tds);
65 8 : tds_free_context(ctx);
66 :
67 : return g_result;
68 : }
|