LCOV - code coverage report
Current view: top level - src/tds/unittests - t0007.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 252 266 94.7 %
Date: 2025-04-25 08:22:23 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
       2             :  * Copyright (C) 1998-1999  Brian Bruns
       3             :  * Copyright (C) 2015  Frediano Ziglio
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU Library General Public
       7             :  * License as published by the Free Software Foundation; either
       8             :  * version 2 of the License, or (at your option) any later version.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  * Library General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Library General Public
      16             :  * License along with this library; if not, write to the
      17             :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      18             :  * Boston, MA 02111-1307, USA.
      19             :  */
      20             : 
      21             : /**
      22             :  * This test exercise manually conversions from types.
      23             :  * Does not require any connection.
      24             :  */
      25             : 
      26             : #include "common.h"
      27             : #include <freetds/convert.h>
      28             : 
      29             : #define TO32(n) ((unsigned int)((unsigned int)(n) & 0xfffffffflu))
      30             : 
      31             : static TDSCONTEXT ctx;
      32             : 
      33             : static void
      34        1400 : test0(const char *src, int len, int midtype, int dsttype, const char *result, int line)
      35             : {
      36             :         int i, res;
      37             :         char buf[256];
      38             :         CONV_RESULT cr, cr_mid, cr_out;
      39        1400 :         int srctype = SYBVARCHAR;
      40             :         char *copy;
      41             : 
      42        1400 :         copy = tds_new(char, (size_t) len);
      43        1400 :         memcpy(copy, src, (size_t) len);
      44        1400 :         src = copy;
      45             : 
      46        1400 :         if (midtype) {
      47         180 :                 if (midtype == SYBNUMERIC || midtype == SYBDECIMAL) {
      48           0 :                         cr_mid.n.precision = 20;
      49           0 :                         cr_mid.n.scale = 8;
      50             :                 }
      51         180 :                 res = tds_convert(&ctx, SYBVARCHAR, src, (TDS_UINT) len, midtype, &cr_mid);
      52         180 :                 if (res < 0) {
      53           0 :                         fprintf(stderr, "Unexpected failure converting %*.*s\n", len, len, src);
      54           0 :                         exit(1);
      55             :                 }
      56             :                 src = (const char *) &cr_mid;
      57             :                 len = res;
      58             :                 srctype = midtype;
      59             :         }
      60        1400 :         if (dsttype == SYBNUMERIC || dsttype == SYBDECIMAL) {
      61          10 :                 cr.n.precision = 20;
      62          10 :                 cr.n.scale = 8;
      63             :         }
      64        1400 :         res = tds_convert(&ctx, srctype, src, (TDS_UINT) len, dsttype, &cr);
      65        1400 :         if (res < 0)
      66         530 :                 strcpy(buf, "error");
      67             :         else {
      68         870 :                 buf[0] = 0;
      69         870 :                 switch (dsttype) {
      70          60 :                 case SYBINT1:
      71             :                 case SYBUINT1:
      72          60 :                         sprintf(buf, "%d", cr.ti);
      73          60 :                         break;
      74          30 :                 case SYBINT2:
      75          30 :                         sprintf(buf, "%d", cr.si);
      76          30 :                         break;
      77          20 :                 case SYBUINT2:
      78          20 :                         sprintf(buf, "%u", cr.usi);
      79          20 :                         break;
      80          90 :                 case SYBINT4:
      81          90 :                         sprintf(buf, "%d", cr.i);
      82          90 :                         break;
      83          50 :                 case SYBUINT4:
      84          50 :                         sprintf(buf, "%u", cr.ui);
      85          50 :                         break;
      86          80 :                 case SYBINT8:
      87          80 :                         sprintf(buf, "0x%08x%08x", TO32(cr.bi >> 32), TO32(cr.bi));
      88          80 :                         break;
      89         150 :                 case SYB5BIGTIME:
      90             :                 case SYB5BIGDATETIME:
      91             :                 case SYBUINT8:
      92         150 :                         sprintf(buf, "0x%08x%08x", TO32(cr.ubi >> 32), TO32(cr.ubi));
      93         150 :                         break;
      94          30 :                 case SYBUNIQUE:
      95         300 :                         sprintf(buf, "%08X-%04X-%04X-%02X%02X%02X%02X"
      96             :                                 "%02X%02X%02X%02X",
      97             :                                 cr.u.Data1,
      98          60 :                                 cr.u.Data2, cr.u.Data3,
      99          60 :                                 cr.u.Data4[0], cr.u.Data4[1],
     100         180 :                                 cr.u.Data4[2], cr.u.Data4[3], cr.u.Data4[4], cr.u.Data4[5], cr.u.Data4[6], cr.u.Data4[7]);
     101          30 :                         break;
     102         130 :                 case SYBBINARY:
     103         130 :                         sprintf(buf, "len=%d", res);
     104         560 :                         for (i = 0; i < res; ++i)
     105         430 :                                 sprintf(strchr(buf, 0), " %02X", (TDS_UCHAR) cr.ib[i]);
     106         130 :                         free(cr.ib);
     107         130 :                         break;
     108          50 :                 case SYBCHAR:
     109          50 :                         sprintf(buf, "len=%d %s", res, cr.c);
     110          50 :                         free(cr.c);
     111          50 :                         break;
     112          90 :                 case SYBDATETIME:
     113          90 :                         sprintf(buf, "%ld %ld", (long int) cr.dt.dtdays, (long int) cr.dt.dttime);
     114          90 :                         break;
     115          40 :                 case SYBDATE:
     116          40 :                         sprintf(buf, "%ld", (long int) cr.date);
     117          40 :                         break;
     118          40 :                 case SYBTIME:
     119          40 :                         sprintf(buf, "%ld", (long int) cr.time);
     120          40 :                         break;
     121          10 :                 case SYBNUMERIC:
     122             :                 case SYBDECIMAL:
     123          10 :                         cr_out.cc.c = buf;
     124          10 :                         cr_out.cc.len = sizeof(buf) - 1;
     125          10 :                         res = tds_convert(&ctx, dsttype, &cr.n, sizeof(cr.n), TDS_CONVERT_CHAR, &cr_out);
     126          10 :                         if (res < 0) {
     127           0 :                                 fprintf(stderr, "Unexpected failure converting %*.*s\n", len, len, src);
     128           0 :                                 exit(1);
     129             :                         }
     130          10 :                         buf[res] = 0;
     131             :                 }
     132             :         }
     133        1400 :         printf("%s\n", buf);
     134        1400 :         if (strcmp(buf, result) != 0) {
     135           0 :                 fprintf(stderr, "Expected '%s' got '%s' at line %d\n", result, buf, line);
     136           0 :                 exit(1);
     137             :         }
     138        1400 :         free(copy);
     139        1400 : }
     140             : 
     141             : #define test(s,d,r)    test0(s,(int)strlen(s),0,d,r,__LINE__)
     142             : #define test2(s,m,d,r) test0(s,(int)strlen(s),m,d,r,__LINE__)
     143             : 
     144             : static int
     145             : int_types[] = {
     146             :         SYBINT1, SYBUINT1, SYBINT2, SYBUINT2,
     147             :         SYBINT4, SYBUINT4, SYBINT8, SYBUINT8,
     148             :         SYBMONEY4, SYBMONEY,
     149             :         SYBNUMERIC,
     150             :         -1
     151             : };
     152             : 
     153             : static const char *
     154             : int_values[] = {
     155             :         "0",
     156             :         "127", "255",
     157             :         "128", "256",
     158             :         "32767", "65535",
     159             :         "32768", "65536",
     160             :         "214748",
     161             :         "214749",
     162             :         "2147483647", "4294967295",
     163             :         "2147483648", "4294967296",
     164             :         "922337203685477",
     165             :         "922337203685478",
     166             :         "9223372036854775807", "18446744073709551615",
     167             :         "9223372036854775808", "18446744073709551616",
     168             :         "-128",
     169             :         "-129",
     170             :         "-32768",
     171             :         "-32769",
     172             :         "-214748",
     173             :         "-214749",
     174             :         "-2147483648",
     175             :         "-2147483649",
     176             :         "-922337203685477",
     177             :         "-922337203685478",
     178             :         "-9223372036854775808",
     179             :         "-9223372036854775809",
     180             :         NULL
     181             : };
     182             : 
     183          10 : TEST_MAIN()
     184             : {
     185             :         int *type1, *type2;
     186             :         const char **value;
     187          10 :         int big_endian = 1;
     188             :         if (((char *) &big_endian)[0] == 1)
     189          10 :                 big_endian = 0;
     190             : 
     191          10 :         memset(&ctx, 0, sizeof(ctx));
     192             : 
     193          10 :         if ((ctx.locale = tds_get_locale()) == NULL)
     194             :                 return 1;
     195             : 
     196             :         /* date */
     197          10 :         free(ctx.locale->datetime_fmt);
     198          10 :         ctx.locale->datetime_fmt = strdup("%Y-%m-%d %H:%M:%S.%z");
     199          10 :         free(ctx.locale->date_fmt);
     200          10 :         ctx.locale->date_fmt = strdup("%Y-%m-%d");
     201          10 :         free(ctx.locale->time_fmt);
     202          10 :         ctx.locale->time_fmt = strdup("%H:%M:%S.%z");
     203             : 
     204             :         /* test some conversion */
     205          10 :         printf("some checks...\n");
     206          10 :         test("1234", SYBINT4, "1234");
     207          10 :         test("1234", SYBUINT4, "1234");
     208          10 :         test("123", SYBINT1, "123");
     209          10 :         test("123", SYBUINT1, "123");
     210          10 :         test("  -    1234   ", SYBINT2, "-1234");
     211          10 :         test("  -    1234   a", SYBINT2, "error");
     212          10 :         test("", SYBINT4, "0");
     213          10 :         test("    ", SYBINT4, "0");
     214          10 :         test("    123", SYBINT4, "123");
     215          10 :         test("    123    ", SYBINT4, "123");
     216          10 :         test("  +  123  ", SYBINT4, "123");
     217          10 :         test("  +  123  ", SYBUINT4, "123");
     218          10 :         test("  - 0  ", SYBINT4, "0");
     219          10 :         test("  -  0  ", SYBUINT4, "0");
     220          10 :         test("+", SYBINT4, "error");
     221          10 :         test("   +", SYBINT4, "error");
     222          10 :         test("+   ", SYBINT4, "error");
     223          10 :         test("   +   ", SYBINT4, "error");
     224          10 :         test("-", SYBINT4, "error");
     225          10 :         test("   -", SYBINT4, "error");
     226          10 :         test("-   ", SYBINT4, "error");
     227          10 :         test("   -   ", SYBINT4, "error");
     228             : 
     229          10 :         test("  -    1234   ", SYBINT8, "0xfffffffffffffb2e");
     230          10 :         test("1234x", SYBINT8, "error");
     231          10 :         test("  -    1234   a", SYBINT8, "error");
     232          10 :         test("", SYBINT8, "0x0000000000000000");
     233          10 :         test("    ", SYBINT8, "0x0000000000000000");
     234          10 :         test("    123", SYBINT8, "0x000000000000007b");
     235          10 :         test("    123    ", SYBINT8, "0x000000000000007b");
     236          10 :         test("  +  123  ", SYBINT8, "0x000000000000007b");
     237          10 :         test("    123", SYBUINT8, "0x000000000000007b");
     238          10 :         test("    123    ", SYBUINT8, "0x000000000000007b");
     239          10 :         test("  +  123  ", SYBUINT8, "0x000000000000007b");
     240          10 :         test("+", SYBINT8, "error");
     241          10 :         test("   +", SYBINT8, "error");
     242          10 :         test("+   ", SYBINT8, "error");
     243          10 :         test("   +   ", SYBINT8, "error");
     244          10 :         test("-", SYBINT8, "error");
     245          10 :         test("   -", SYBINT8, "error");
     246          10 :         test("-   ", SYBINT8, "error");
     247          10 :         test("   -   ", SYBINT8, "error");
     248             : 
     249             :         /* test for overflow */
     250             :         /* for SYBUINT8 a test with all different digit near limit is required */
     251          10 :         printf("overflow checks...\n");
     252          10 :         test("9223372036854775807", SYBINT8, "0x7fffffffffffffff");
     253          10 :         test("9223372036854775807", SYBUINT8, "0x7fffffffffffffff");
     254          10 :         test("9223372036854775808", SYBINT8, "error");
     255          10 :         test("-9223372036854775808", SYBINT8, "0x8000000000000000");
     256          10 :         test("9223372036854775808", SYBUINT8, "0x8000000000000000");
     257          10 :         test("18446744073709551610", SYBUINT8, "0xfffffffffffffffa");
     258          10 :         test("18446744073709551611", SYBUINT8, "0xfffffffffffffffb");
     259          10 :         test("18446744073709551612", SYBUINT8, "0xfffffffffffffffc");
     260          10 :         test("18446744073709551613", SYBUINT8, "0xfffffffffffffffd");
     261          10 :         test("18446744073709551614", SYBUINT8, "0xfffffffffffffffe");
     262          10 :         test("18446744073709551615", SYBUINT8, "0xffffffffffffffff");
     263          10 :         test("18446744073709551616", SYBUINT8, "error");
     264          10 :         test("18446744073709551617", SYBUINT8, "error");
     265          10 :         test("18446744073709551618", SYBUINT8, "error");
     266          10 :         test("18446744073709551619", SYBUINT8, "error");
     267          10 :         test("18446744073709551620", SYBUINT8, "error");
     268          10 :         test("20496382304121724025", SYBUINT8, "error");
     269          10 :         test("20496382308118429681", SYBUINT8, "error");
     270          10 :         test("-1", SYBUINT8, "error");
     271          10 :         test("-9223372036854775809", SYBINT8, "error");
     272          10 :         test("2147483647", SYBINT4, "2147483647");
     273          10 :         test("2147483648", SYBINT4, "error");
     274          10 :         test("2147483647", SYBUINT4, "2147483647");
     275          10 :         test("4294967295", SYBUINT4, "4294967295");
     276          10 :         test("4294967296", SYBUINT4, "error");
     277          10 :         test("-2147483648", SYBINT4, "-2147483648");
     278          10 :         test("-2147483648", SYBUINT4, "error");
     279          10 :         test("-2147483649", SYBINT4, "error");
     280          10 :         test("32767", SYBINT2, "32767");
     281          10 :         test("32767", SYBUINT2, "32767");
     282          10 :         test("65535", SYBUINT2, "65535");
     283          10 :         test("65536", SYBUINT2, "error");
     284          10 :         test("32768", SYBINT2, "error");
     285          10 :         test("-32768", SYBINT2, "-32768");
     286          10 :         test("-32769", SYBINT2, "error");
     287          10 :         test("255", SYBINT1, "255");
     288          10 :         test("256", SYBINT1, "error");
     289          10 :         test("255", SYBUINT1, "255");
     290          10 :         test("256", SYBUINT1, "error");
     291          10 :         test("0", SYBINT1, "0");
     292          10 :         test("-1", SYBINT1, "error");
     293          10 :         test("0", SYBUINT1, "0");
     294          10 :         test("-1", SYBUINT1, "error");
     295             : 
     296             :         /*
     297             :          * test overflow on very big numbers 
     298             :          * I use increment of 10^9 to be sure lower 32bit be correct
     299             :          * in a case
     300             :          */
     301          10 :         printf("overflow on big number checks...\n");
     302          10 :         test("62147483647", SYBINT4, "error");
     303          10 :         test("63147483647", SYBINT4, "error");
     304          10 :         test("64147483647", SYBINT4, "error");
     305          10 :         test("65147483647", SYBINT4, "error");
     306          10 :         test("53248632876323876761", SYBINT8, "error");
     307          10 :         test("56248632876323876761", SYBINT8, "error");
     308          10 :         test("59248632876323876761", SYBINT8, "error");
     309          10 :         test("12248632876323876761", SYBINT8, "error");
     310             : 
     311             :         /* money */
     312          10 :         test2("1234.11111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
     313             :                 SYBMONEY, SYBCHAR, "len=9 1234.1111");
     314             : 
     315             :         /* some test for unique */
     316          10 :         printf("unique type...\n");
     317          10 :         test("12345678-1234-1234-9876543298765432", SYBUNIQUE, "12345678-1234-1234-9876543298765432");
     318          10 :         test("{12345678-1234-1E34-9876ab3298765432}", SYBUNIQUE, "12345678-1234-1E34-9876AB3298765432");
     319          10 :         test(" 12345678-1234-1234-9876543298765432", SYBUNIQUE, "error");
     320          10 :         test(" {12345678-1234-1234-9876543298765432}", SYBUNIQUE, "error");
     321          10 :         test("12345678-1234-G234-9876543298765432", SYBUNIQUE, "error");
     322          10 :         test("12345678-1234-a234-9876543298765432", SYBUNIQUE, "12345678-1234-A234-9876543298765432");
     323          10 :         test("123a5678-1234-a234-98765-43298765432", SYBUNIQUE, "error");
     324          10 :         test("123-5678-1234-a234-9876543298765432", SYBUNIQUE, "error");
     325             : 
     326          10 :         printf("binary test...\n");
     327          10 :         test("0x1234", SYBBINARY, "len=2 12 34");
     328          10 :         test("0xaBFd  ", SYBBINARY, "len=2 AB FD");
     329          10 :         test("AbfD  ", SYBBINARY, "len=2 AB FD");
     330          10 :         test("0x000", SYBBINARY, "len=2 00 00");
     331          10 :         test("0x0", SYBBINARY, "len=1 00");
     332          10 :         test("0x100", SYBBINARY, "len=2 01 00");
     333          10 :         test("0x1", SYBBINARY, "len=1 01");
     334             : 
     335          10 :         test("Jan 01 2006", SYBDATETIME, "38716 0");
     336          10 :         test("January 01 2006", SYBDATETIME, "38716 0");
     337          10 :         test("March 05 2005", SYBDATETIME, "38414 0");
     338          10 :         test("may 13 2001", SYBDATETIME, "37022 0");
     339             : 
     340          10 :         test("02 Jan 2006", SYBDATETIME, "38717 0");
     341          10 :         test("2 Jan 2006", SYBDATETIME, "38717 0");
     342          10 :         test("02Jan2006", SYBDATETIME, "38717 0");
     343          10 :         test("20060102", SYBDATETIME, "38717 0");
     344          10 :         test("060102", SYBDATETIME, "38717 0");
     345             : 
     346          10 :         test("2006-01-02", SYBDATE, "38717");
     347          10 :         test("12:34:56.337", SYBTIME, "13588901");
     348             : 
     349          10 :         test2("2006-01-02", SYBDATE, SYBDATE, "38717");
     350          10 :         test2("12:34:56.337", SYBTIME, SYBTIME, "13588901");
     351             : 
     352          10 :         test2("2006-01-02 12:34:56.337", SYBDATETIME, SYBDATE, "38717");
     353          10 :         test2("2006-01-02 12:34:56.337", SYBDATETIME, SYBTIME, "13588901");
     354             : 
     355          10 :         test("2006-01-02 12:34:56.337321", SYB5BIGTIME, "0x0000000a8bdf41a9");
     356          10 :         test("2006-01-23 12:34:56.337321", SYB5BIGDATETIME, "0x00e0e7c784d661a9");
     357          10 :         test("2006-01-02 12:34:56.337321", SYB5BIGDATETIME, "0x00e0e621122b81a9");
     358             : 
     359          10 :         test2("2006-01-02 12:34:56.337765", SYB5BIGDATETIME, SYBCHAR, "len=26 2006-01-02 12:34:56.337765");
     360          10 :         test("2006-01-02 12:34:56.337765", SYB5BIGDATETIME, "0x00e0e621122b8365");
     361             : 
     362          10 :         test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBDATE, "38717");
     363          10 :         test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBTIME, "13588901");
     364             : 
     365          10 :         test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBCHAR, "len=27 2006-01-02 12:34:56.3370000");
     366             : #if 0
     367             :         /* FIXME should fail conversion ?? */
     368             :         test2("2006-01-02", SYBDATE, SYBTIME, "0");
     369             :         test2("12:34:56.337", SYBTIME, SYBDATE, "0");
     370             : #endif
     371             : 
     372          10 :         test2("2006-01-02", SYBDATE, SYBCHAR, "len=10 2006-01-02");
     373          10 :         test2("12:34:56.337", SYBTIME, SYBCHAR, "len=12 12:34:56.337");
     374             : 
     375          10 :         test2("123", SYBINT1, SYBBINARY, "len=1 7B");
     376          10 :         test2("0.000001", SYBFLT8, SYBNUMERIC, "0.00000100");
     377             :         if (big_endian) {
     378             :                 test2("12345", SYBINT2, SYBBINARY, "len=2 30 39");
     379             :                 test2("123456789", SYBINT4, SYBBINARY, "len=4 07 5B CD 15");
     380             :                 test2("123456789", SYBUINT8, SYBBINARY, "len=8 00 00 00 00 07 5B CD 15");
     381             :                 test2("123456789", SYBINT8, SYBBINARY, "len=8 00 00 00 00 07 5B CD 15");
     382             :                 test2("-123456789", SYBINT8, SYBBINARY, "len=8 FF FF FF FF F8 A4 32 EB");
     383             :         } else {
     384          10 :                 test2("12345", SYBINT2, SYBBINARY, "len=2 39 30");
     385          10 :                 test2("123456789", SYBINT4, SYBBINARY, "len=4 15 CD 5B 07");
     386          10 :                 test2("123456789", SYBUINT8, SYBBINARY, "len=8 15 CD 5B 07 00 00 00 00");
     387          10 :                 test2("123456789", SYBINT8, SYBBINARY, "len=8 15 CD 5B 07 00 00 00 00");
     388          10 :                 test2("-123456789", SYBINT8, SYBBINARY, "len=8 EB 32 A4 F8 FF FF FF FF");
     389             :         }
     390             : 
     391             :         /* now try many int conversion operations */
     392         340 :         for (value = int_values; *value; ++value)
     393        3630 :         for (type1 = int_types; *type1 >= 0; ++type1)
     394       39930 :         for (type2 = int_types; *type2 >= 0; ++type2) {
     395             :                 char buf[64], expected[64];
     396             :                 CONV_RESULT cr_src, cr_dst;
     397             :                 TDS_INT len_src, len_dst;
     398             : 
     399             :                 /* try conversion from char (already tested above) */
     400       39930 :                 cr_src.n.precision = 20; cr_src.n.scale = 0;
     401       39930 :                 len_src = tds_convert(&ctx, SYBVARCHAR, *value, (TDS_UINT) strlen(*value), *type1, &cr_src);
     402       39930 :                 cr_dst.n.precision = 20; cr_dst.n.scale = 0;
     403       39930 :                 len_dst = tds_convert(&ctx, SYBVARCHAR, *value, (TDS_UINT) strlen(*value), *type2, &cr_dst);
     404       39930 :                 if (len_src <= 0 || len_dst <= 0)
     405       27230 :                         continue;
     406       12700 :                 cr_dst.n.precision = 20; cr_dst.n.scale = 0;
     407       12700 :                 if (tds_convert(&ctx, *type1, &cr_src.i, (TDS_UINT) len_src, *type2, &cr_dst) <= 0) {
     408           0 :                         fprintf(stderr, "conversion from %s to %s of %s should succeed\n",
     409             :                                 tds_prtype(*type1), tds_prtype(*type2), *value);
     410           0 :                         return 1;
     411             :                 }
     412       12700 :                 memcpy(&cr_src, &cr_dst, sizeof(cr_dst));
     413       12700 :                 cr_dst.cc.c = buf;
     414       12700 :                 cr_dst.cc.len = sizeof(buf)-4;
     415       12700 :                 len_dst = tds_convert(&ctx, *type2, &cr_src.i, (TDS_UINT) len_dst, TDS_CONVERT_CHAR, &cr_dst);
     416       12700 :                 if (len_dst <= 0) {
     417           0 :                         fprintf(stderr, "conversion from %s to string should succeed\n",
     418             :                                 tds_prtype(*type1));
     419           0 :                         return 1;
     420             :                 }
     421       12700 :                 buf[len_dst] = 0;
     422       12700 :                 if (*type2 == SYBMONEY4 || *type2 == SYBMONEY)
     423        2840 :                         sprintf(expected, "%s.0000", *value);
     424             :                 else
     425        9860 :                         strcpy(expected, *value);
     426       12700 :                 if (strcmp(buf, expected) != 0) {
     427           0 :                         fprintf(stderr, "conversion from %s to %s of %s got wrong value '%s'\n",
     428             :                                 tds_prtype(*type1), tds_prtype(*type2), *value, buf);
     429           0 :                         return 1;
     430             :                 }
     431             :         }
     432             : 
     433          10 :         tds_free_locale(ctx.locale);
     434             : 
     435          10 :         return 0;
     436             : }

Generated by: LCOV version 1.13