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 11:50:39 Functions: 2 2 100.0 %

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

Generated by: LCOV version 1.13