LCOV - code coverage report
Current view: top level - src/ctlib/unittests - ct_options.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 33 46 71.7 %
Date: 2025-02-21 09:36:06 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : 
       3             : /* Testing: Set and get options with ct_options */
       4             : int
       5          10 : main(int argc, char *argv[])
       6             : {
       7          10 :         int verbose = 0;
       8             : 
       9             :         CS_CONTEXT *ctx;
      10             :         CS_CONNECTION *conn;
      11             :         CS_COMMAND *cmd;
      12             : 
      13          10 :         CS_INT datefirst = 0;
      14          10 :         CS_INT dateformat = 0;
      15          10 :         CS_BOOL truefalse = 999;
      16             : 
      17             :         if (verbose) {
      18             :                 printf("Trying login\n");
      19             :         }
      20             : 
      21          10 :         if (argc >= 5) {
      22           0 :                 common_pwd.initialized = argc;
      23           0 :                 strcpy(common_pwd.SERVER, argv[1]);
      24           0 :                 strcpy(common_pwd.DATABASE, argv[2]);
      25           0 :                 strcpy(common_pwd.USER, argv[3]);
      26           0 :                 strcpy(common_pwd.PASSWORD, argv[4]);
      27             :         }
      28             : 
      29          10 :         check_call(try_ctlogin, (&ctx, &conn, &cmd, verbose));
      30             : 
      31          10 :         printf("%s: Set/Retrieve DATEFIRST\n", __FILE__);
      32             : 
      33             :         /* DATEFIRST */
      34          10 :         datefirst = CS_OPT_WEDNESDAY;
      35          10 :         check_call(ct_options, (conn, CS_SET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL));
      36             : 
      37          10 :         datefirst = 999;
      38             : 
      39          10 :         check_call(ct_options, (conn, CS_GET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL));
      40          10 :         if (datefirst != CS_OPT_WEDNESDAY) {
      41           0 :                 fprintf(stderr, "ct_options(DATEFIRST) didn't work retrieved %d expected %d\n", datefirst, CS_OPT_WEDNESDAY);
      42           0 :                 return 1;
      43             :         }
      44             : 
      45          10 :         printf("%s: Set/Retrieve DATEFORMAT\n", __FILE__);
      46             : 
      47             :         /* DATEFORMAT */
      48          10 :         dateformat = CS_OPT_FMTMYD;
      49          10 :         check_call(ct_options, (conn, CS_SET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL));
      50             : 
      51          10 :         dateformat = 999;
      52             : 
      53          10 :         check_call(ct_options, (conn, CS_GET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL));
      54          10 :         if (dateformat != CS_OPT_FMTMYD) {
      55           0 :                 fprintf(stderr, "ct_options(DATEFORMAT) didn't work retrieved %d expected %d\n", dateformat, CS_OPT_FMTMYD);
      56           0 :                 return 1;
      57             :         }
      58             : 
      59          10 :         printf("%s: Set/Retrieve ANSINULL\n", __FILE__);
      60             :         /* ANSI NULLS */
      61          10 :         truefalse = CS_TRUE;
      62          10 :         check_call(ct_options, (conn, CS_SET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL));
      63             : 
      64          10 :         truefalse = 999;
      65          10 :         check_call(ct_options, (conn, CS_GET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL));
      66          10 :         if (truefalse != CS_TRUE) {
      67           0 :                 fprintf(stderr, "ct_options(ANSINULL) didn't work\n");
      68           0 :                 return 1;
      69             :         }
      70             : 
      71          10 :         printf("%s: Set/Retrieve CHAINXACTS\n", __FILE__);
      72             :         /* CHAINED XACT */
      73          10 :         truefalse = CS_TRUE;
      74          10 :         check_call(ct_options, (conn, CS_SET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL));
      75             : 
      76          10 :         truefalse = 999;
      77          10 :         check_call(ct_options, (conn, CS_GET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL));
      78          10 :         if (truefalse != CS_TRUE) {
      79           0 :                 fprintf(stderr, "ct_options(CHAINXACTS) didn't work\n");
      80           0 :                 return 1;
      81             :         }
      82             : 
      83             :         if (verbose) {
      84             :                 printf("Trying logout\n");
      85             :         }
      86          10 :         check_call(try_ctlogout, (ctx, conn, cmd, verbose));
      87             : 
      88          10 :         return 0;
      89             : }

Generated by: LCOV version 1.13