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