LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/compat_informix - rnull.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 65 65 100.0 %
Date: 2019-11-13 22:07:24 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "sqltypes.h"
       2             : #include <stdlib.h>
       3             : 
       4             : $include ../regression;
       5             : $define NUMBER 12;
       6             : 
       7             : static void
       8          80 : test_null(int type, char *ptr)
       9             : {
      10          80 :     printf("null: %d\n", risnull(type, ptr));
      11          80 : }
      12             : 
      13           4 : int main(void)
      14             : {
      15           4 :     $char c[] = "abc";
      16           4 :     $short s = 17;
      17           4 :     $int i = -74874;
      18           4 :     $bool b = 1;
      19           4 :     $float f = 3.71;
      20           4 :     $long l = 487444;
      21           4 :     $double dbl = 404.404;
      22             :     $decimal dec;
      23             :     $date dat;
      24             :     $timestamp tmp;
      25             : 
      26           4 :     ECPGdebug(1, stderr);
      27             :     $whenever sqlerror do sqlprint();
      28             : 
      29           4 :     $connect to REGRESSDB1;
      30           4 : 
      31           4 :     $create table test(id int, c char(10), s smallint, i int, b bool,
      32             :                        f float, l bigint, dbl double precision,
      33             :                        dec decimal, dat date, tmp timestamptz);
      34           4 :     $commit;
      35           4 : 
      36           4 :     $insert into test (id, c, s, i, b, f, l, dbl) values (
      37             :         1, :c, :s, :i, :b, :f, :l, :dbl
      38             :     );
      39           4 :     $commit;
      40           4 : 
      41           4 :     rsetnull(CCHARTYPE, (char *) c);
      42           4 :     rsetnull(CSHORTTYPE, (char *) &s);
      43           4 :     rsetnull(CINTTYPE, (char *) &i);
      44           4 :     rsetnull(CBOOLTYPE, (char *) &b);
      45           4 :     rsetnull(CFLOATTYPE, (char *) &f);
      46           4 :     rsetnull(CLONGTYPE, (char *) &l);
      47           4 :     rsetnull(CDOUBLETYPE, (char *) &dbl);
      48           4 :     rsetnull(CDECIMALTYPE, (char *) &dec);
      49           4 :     rsetnull(CDATETYPE, (char *) &dat);
      50           4 :     rsetnull(CDTIMETYPE, (char *) &tmp);
      51             : 
      52           4 :     $insert into test (id, c, s, i, b, f, l, dbl, dec, dat, tmp) values (
      53             :         2, :c, :s, :i, :b, :f, :l, :dbl, :dec, :dat, :tmp
      54             :     );
      55           4 :     $commit;
      56           4 : 
      57           4 :     printf("first select\n");
      58             : 
      59           4 :     $select c, s, i, b, f, l, dbl, dec, dat, tmp
      60             :         into :c, :s, :i, :b, :f, :l, :dbl, :dec, :dat, :tmp
      61             :         from test where id = 1;
      62           4 : 
      63           4 :     test_null(CCHARTYPE, (char *) c);
      64           4 :     test_null(CSHORTTYPE, (char *) &s);
      65           4 :     test_null(CINTTYPE, (char *) &i);
      66           4 :     test_null(CBOOLTYPE, (char *) &b);
      67           4 :     test_null(CFLOATTYPE, (char *) &f);
      68           4 :     test_null(CLONGTYPE, (char *) &l);
      69           4 :     test_null(CDOUBLETYPE, (char *) &dbl);
      70           4 :     test_null(CDECIMALTYPE, (char *) &dec);
      71           4 :     test_null(CDATETYPE, (char *) &dat);
      72           4 :     test_null(CDTIMETYPE, (char *) &tmp);
      73             : 
      74           4 :     printf("second select\n");
      75             : 
      76           4 :     $select c, s, i, b, f, l, dbl, dec, dat, tmp
      77             :         into :c, :s, :i, :b, :f, :l, :dbl, :dec, :dat, :tmp
      78             :         from test where id = 2;
      79           4 : 
      80           4 :     test_null(CCHARTYPE, (char *) c);
      81           4 :     test_null(CSHORTTYPE, (char *) &s);
      82           4 :     test_null(CINTTYPE, (char *) &i);
      83           4 :     test_null(CBOOLTYPE, (char *) &b);
      84           4 :     test_null(CFLOATTYPE, (char *) &f);
      85           4 :     test_null(CLONGTYPE, (char *) &l);
      86           4 :     test_null(CDOUBLETYPE, (char *) &dbl);
      87           4 :     test_null(CDECIMALTYPE, (char *) &dec);
      88           4 :     test_null(CDATETYPE, (char *) &dat);
      89           4 :     test_null(CDTIMETYPE, (char *) &tmp);
      90             : 
      91           4 :     $drop table test;
      92           4 :     $commit;
      93           4 : 
      94           4 :     $close database;
      95           4 : 
      96           4 :     return 0;
      97             : }

Generated by: LCOV version 1.13