LTP GCOV extension - code coverage report
Current view: directory - odbc/unittests - t0001.c
Test: FreeTDS coverage
Date: 2009-01-08 Instrumented lines: 48
Code covered: 47.9 % Executed lines: 23

       1                 : #include "common.h"
       2                 : 
       3                 : static char software_version[] = "$Id: t0001.c,v 1.14 2004/10/28 13:16:18 freddy77 Exp $";
       4                 : static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
       5                 : 
       6                 : int
       7                 : main(int argc, char *argv[])
       8               2 : {
       9                 : 
      10                 :         int res;
      11                 :         int i;
      12                 : 
      13                 :         SQLLEN cnamesize;
      14                 : 
      15                 :         const char *command;
      16                 :         SQLCHAR output[256];
      17                 : 
      18               2 :         Connect();
      19                 : 
      20               2 :         if (CommandWithResult(Statement, "drop table #odbctestdata") != SQL_SUCCESS)
      21               2 :                 printf("Unable to execute statement\n");
      22                 : 
      23               2 :         command = "create table #odbctestdata ("
      24                 :                 "col1 varchar(30) not null,"
      25                 :                 "col2 int not null,"
      26                 :                 "col3 float not null," "col4 numeric(18,6) not null," "col5 datetime not null," "col6 text not null)";
      27               2 :         if (CommandWithResult(Statement, command) != SQL_SUCCESS) {
      28               0 :                 printf("Unable to execute statement\n");
      29               0 :                 CheckReturn();
      30               0 :                 exit(1);
      31                 :         }
      32                 : 
      33               2 :         command = "insert #odbctestdata values ("
      34                 :                 "'ABCDEFGHIJKLMNOP',"
      35                 :                 "123456," "1234.56," "123456.78," "'Sep 11 2001 10:00AM'," "'just to check returned length...')";
      36               2 :         if (CommandWithResult(Statement, command) != SQL_SUCCESS) {
      37               0 :                 printf("Unable to execute statement\n");
      38               0 :                 CheckReturn();
      39               0 :                 exit(1);
      40                 :         }
      41                 : 
      42               2 :         if (CommandWithResult(Statement, "select * from #odbctestdata") != SQL_SUCCESS) {
      43               0 :                 printf("Unable to execute statement\n");
      44               0 :                 CheckReturn();
      45               0 :                 exit(1);
      46                 :         }
      47                 : 
      48               2 :         res = SQLFetch(Statement);
      49               2 :         if (res != SQL_SUCCESS && res != SQL_SUCCESS_WITH_INFO) {
      50               0 :                 printf("Unable to fetch row\n");
      51               0 :                 CheckReturn();
      52               0 :                 exit(1);
      53                 :         }
      54                 : 
      55              14 :         for (i = 1; i <= 6; i++) {
      56              12 :                 if (SQLGetData(Statement, i, SQL_C_CHAR, output, sizeof(output), &cnamesize) != SQL_SUCCESS) {
      57               0 :                         printf("Unable to get data col %d\n", i);
      58               0 :                         CheckReturn();
      59               0 :                         exit(1);
      60                 :                 }
      61                 : 
      62              12 :                 printf("output data >%s< len_or_ind = %d\n", output, (int) cnamesize);
      63              12 :                 if (cnamesize != strlen((char *) output))
      64               0 :                         return 1;
      65                 :         }
      66                 : 
      67               2 :         res = SQLFetch(Statement);
      68               2 :         if (res != SQL_NO_DATA) {
      69               0 :                 printf("Unable to fetch row\n");
      70               0 :                 CheckReturn();
      71               0 :                 exit(1);
      72                 :         }
      73                 : 
      74               2 :         res = SQLCloseCursor(Statement);
      75               2 :         if (!SQL_SUCCEEDED(res)) {
      76               0 :                 printf("Unable to close cursr\n");
      77               0 :                 CheckReturn();
      78               0 :                 exit(1);
      79                 :         }
      80                 : 
      81               2 :         if (CommandWithResult(Statement, "drop table #odbctestdata") != SQL_SUCCESS) {
      82               0 :                 printf("Unable to drop table #odbctestdata \n");
      83               0 :                 CheckReturn();
      84               0 :                 exit(1);
      85                 :         }
      86                 : 
      87               2 :         Disconnect();
      88                 : 
      89               2 :         printf("Done.\n");
      90               2 :         return 0;
      91                 : }

Generated by: LTP GCOV extension version 1.6