LCOV - code coverage report
Current view: top level - src/odbc/unittests - date.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 20 22 90.9 %
Date: 2025-01-18 12:13:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : 
       3             : 
       4             : static char software_version[] = "$Id: date.c,v 1.14 2011-07-12 10:16:59 freddy77 Exp $";
       5             : static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
       6             : 
       7             : static void
       8          16 : DoTest(int n)
       9             : {
      10             :         SQLCHAR output[256];
      11             : 
      12             :         SQLSMALLINT colType;
      13             :         SQLULEN colSize;
      14             :         SQLSMALLINT colScale, colNullable;
      15             :         SQLLEN dataSize;
      16             : 
      17             :         TIMESTAMP_STRUCT ts;
      18             : 
      19          16 :         odbc_command("select convert(datetime, '2002-12-27 18:43:21')");
      20             : 
      21          16 :         CHKFetch("SI");
      22          16 :         CHKDescribeCol(1, (SQLTCHAR*)output, sizeof(output)/sizeof(SQLWCHAR), NULL, &colType, &colSize, &colScale, &colNullable, "S");
      23             : 
      24          16 :         if (n == 0) {
      25           8 :                 memset(&ts, 0, sizeof(ts));
      26           8 :                 CHKGetData(1, SQL_C_TIMESTAMP, &ts, sizeof(ts), &dataSize, "S");
      27           8 :                 sprintf((char *) output, "%04d-%02d-%02d %02d:%02d:%02d.000", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second);
      28             :         } else {
      29           8 :                 CHKGetData(1, SQL_C_CHAR, output, sizeof(output), &dataSize, "S");
      30             :         }
      31             : 
      32          16 :         printf("Date returned: %s\n", output);
      33          16 :         if (strcmp((char *) output, "2002-12-27 18:43:21.000") != 0) {
      34           0 :                 fprintf(stderr, "Invalid returned date\n");
      35           0 :                 exit(1);
      36             :         }
      37             : 
      38          16 :         CHKFetch("No");
      39          16 :         CHKCloseCursor("SI");
      40          16 : }
      41             : 
      42             : int
      43           8 : main(int argc, char *argv[])
      44             : {
      45           8 :         odbc_connect();
      46             : 
      47           8 :         DoTest(0);
      48           8 :         DoTest(1);
      49             : 
      50           8 :         odbc_disconnect();
      51             : 
      52           8 :         printf("Done.\n");
      53             :         return 0;
      54             : }

Generated by: LCOV version 1.13