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-01-18 11:50:39 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           8 : main(int argc, char *argv[])
       6             : {
       7           8 :         int verbose = 0;
       8             : 
       9             :         CS_CONTEXT *ctx;
      10             :         CS_CONNECTION *conn;
      11             :         CS_COMMAND *cmd;
      12             : 
      13           8 :         CS_INT datefirst = 0;
      14           8 :         CS_INT dateformat = 0;
      15           8 :         CS_BOOL truefalse = 999;
      16             : 
      17             :         if (verbose) {
      18             :                 printf("Trying login\n");
      19             :         }
      20             : 
      21           8 :         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           8 :         check_call(try_ctlogin, (&ctx, &conn, &cmd, verbose));
      30             : 
      31           8 :         printf("%s: Set/Retrieve DATEFIRST\n", __FILE__);
      32             : 
      33             :         /* DATEFIRST */
      34           8 :         datefirst = CS_OPT_WEDNESDAY;
      35           8 :         check_call(ct_options, (conn, CS_SET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL));
      36             : 
      37           8 :         datefirst = 999;
      38             : 
      39           8 :         check_call(ct_options, (conn, CS_GET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL));
      40           8 :         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           8 :         printf("%s: Set/Retrieve DATEFORMAT\n", __FILE__);
      46             : 
      47             :         /* DATEFORMAT */
      48           8 :         dateformat = CS_OPT_FMTMYD;
      49           8 :         check_call(ct_options, (conn, CS_SET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL));
      50             : 
      51           8 :         dateformat = 999;
      52             : 
      53           8 :         check_call(ct_options, (conn, CS_GET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL));
      54           8 :         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           8 :         printf("%s: Set/Retrieve ANSINULL\n", __FILE__);
      60             :         /* ANSI NULLS */
      61           8 :         truefalse = CS_TRUE;
      62           8 :         check_call(ct_options, (conn, CS_SET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL));
      63             : 
      64           8 :         truefalse = 999;
      65           8 :         check_call(ct_options, (conn, CS_GET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL));
      66           8 :         if (truefalse != CS_TRUE) {
      67           0 :                 fprintf(stderr, "ct_options(ANSINULL) didn't work\n");
      68           0 :                 return 1;
      69             :         }
      70             : 
      71           8 :         printf("%s: Set/Retrieve CHAINXACTS\n", __FILE__);
      72             :         /* CHAINED XACT */
      73           8 :         truefalse = CS_TRUE;
      74           8 :         check_call(ct_options, (conn, CS_SET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL));
      75             : 
      76           8 :         truefalse = 999;
      77           8 :         check_call(ct_options, (conn, CS_GET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL));
      78           8 :         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           8 :         check_call(try_ctlogout, (ctx, conn, cmd, verbose));
      87             : 
      88           8 :         return 0;
      89             : }

Generated by: LCOV version 1.13