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