LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/compat_informix - rfmtdate.pgc (source / functions) Coverage Total Hit
Test: Code coverage Lines: 0.0 % 103 0
Test Date: 2026-01-26 10:56:24 Functions: 0.0 % 5 0
Legend: Lines:     hit not hit

            Line data    Source code
       1              : #include <stdio.h>
       2              : #include <stdlib.h>
       3              : #include <pgtypes_error.h>
       4              : #include <sqltypes.h>
       5              : 
       6              : /*
       7              :  * This file tests various forms of date-input/output by means of
       8              :  * rfmtdate / rdefmtdate / rstrdate
       9              :  */
      10              : 
      11              : 
      12              : static void
      13              : check_return(int ret);
      14              : 
      15              : static void
      16            0 : date_test_strdate(const char *input)
      17              : {
      18              :         static int i;
      19            0 :         date d;
      20            0 :         int r, q;
      21            0 :         char dbuf[11];
      22              : 
      23            0 :         r = rstrdate(input, &d);
      24            0 :         printf("r: %d ", r);
      25            0 :         if (r == 0)
      26              :         {
      27            0 :                 q = rdatestr(d, dbuf);
      28            0 :                 printf("q: %d ", q);
      29            0 :                 if (q == 0)
      30              :                 {
      31            0 :                         printf("date %d: %s\n", i++, dbuf);
      32            0 :                 }
      33              :                 else
      34            0 :                         printf("\n");
      35            0 :         }
      36              :         else
      37            0 :                 check_return(r);
      38            0 : }
      39              : 
      40              : static void
      41            0 : date_test_defmt(const char *fmt, const char *input)
      42              : {
      43              :         static int i;
      44            0 :         char dbuf[11];
      45            0 :         date d;
      46            0 :         int q, r;
      47              : 
      48            0 :         r = rdefmtdate(&d, fmt, input);
      49            0 :         printf("r: %d ", r);
      50            0 :         if (r == 0)
      51              :         {
      52            0 :                 q = rdatestr(d, dbuf);
      53            0 :                 printf("q: %d ", q);
      54            0 :                 if (q == 0)
      55              :                 {
      56            0 :                         printf("date %d: %s\n", i++, dbuf);
      57            0 :                 }
      58              :                 else
      59            0 :                         printf("\n");
      60            0 :         }
      61              :         else
      62            0 :                 check_return(r);
      63            0 : }
      64              : 
      65              : static void
      66            0 : date_test_fmt(date d, const char *fmt)
      67              : {
      68              :         static int i;
      69            0 :         char buf[200];
      70            0 :         int r;
      71              : 
      72            0 :         r = rfmtdate(d, fmt, buf);
      73            0 :         printf("r: %d ", r);
      74            0 :         if (r != 0)
      75            0 :                 check_return(r);
      76              :         else
      77            0 :                 printf("date: %d: %s\n", i++, buf);
      78            0 : }
      79              : 
      80              : 
      81              : int
      82            0 : main(void)
      83              : {
      84            0 :         short mdy[3] = { 11, 23, 1959 };
      85            0 :         char dbuf[11];
      86            0 :         date d;
      87            0 :         int r;
      88              : 
      89            0 :         ECPGdebug(1, stderr);
      90              : 
      91            0 :         r = rmdyjul(mdy, &d);
      92            0 :         printf("create: r: %d\n", r);
      93            0 :         if (r == 0)
      94              :         {
      95            0 :                 rdatestr(d, dbuf);
      96            0 :                 printf("date: %s\n", dbuf);
      97            0 :         }
      98              : 
      99              :         /* input mask is mmddyyyy */
     100            0 :         date_test_strdate("12031994");
     101            0 :         date_test_strdate("9.6.1994");
     102              : 
     103            0 :         date_test_fmt(d, "mmddyy");
     104            0 :         date_test_fmt(d, "ddmmyy");
     105            0 :         date_test_fmt(d, "yymmdd");
     106            0 :         date_test_fmt(d, "yy/mm/dd");
     107            0 :         date_test_fmt(d, "yy mm dd");
     108            0 :         date_test_fmt(d, "yy.mm.dd");
     109            0 :         date_test_fmt(d, ".mm.yyyy.dd.");
     110            0 :         date_test_fmt(d, "mmm. dd, yyyy");
     111            0 :         date_test_fmt(d, "mmm dd yyyy");
     112            0 :         date_test_fmt(d, "yyyy dd mm");
     113            0 :         date_test_fmt(d, "ddd, mmm. dd, yyyy");
     114            0 :         date_test_fmt(d, "(ddd) mmm. dd, yyyy");
     115              : 
     116            0 :         date_test_defmt("ddmmyy", "21-2-54");
     117            0 :         date_test_defmt("ddmmyy", "2-12-54");
     118            0 :         date_test_defmt("ddmmyy", "20111954");
     119            0 :         date_test_defmt("ddmmyy", "130464");
     120            0 :         date_test_defmt("mmm.dd.yyyy", "MAR-12-1967");
     121            0 :         date_test_defmt("yy/mm/dd", "1954, February 3rd");
     122            0 :         date_test_defmt("mmm.dd.yyyy", "041269");
     123            0 :         date_test_defmt("yy/mm/dd", "In the year 2525, in the month of July, mankind will be alive on the 28th day");
     124            0 :         date_test_defmt("dd-mm-yy", "I said on the 28th of July in the year 2525");
     125            0 :         date_test_defmt("mmm.dd.yyyy", "9/14/58");
     126            0 :         date_test_defmt("yy/mm/dd", "47/03/29");
     127            0 :         date_test_defmt("mmm.dd.yyyy", "oct 28 1975");
     128            0 :         date_test_defmt("mmddyy", "Nov 14th, 1985");
     129              :         /* ok: still contains dd mm yy */
     130            0 :         date_test_defmt("bladdfoommbaryybong", "20/11/1954");
     131              :         /* 1994 is not a leap year, it accepts the date as 01-03-1994 */
     132            0 :         date_test_defmt("ddmmyy", "29-02-1994");
     133              : 
     134              :         /* ECPG_INFORMIX_ENOTDMY, need "dd", "mm" and "yy" */
     135            0 :         date_test_defmt("dmy", "20/11/1954");
     136              : 
     137              :         /* ECPG_INFORMIX_ENOSHORTDATE */
     138            0 :         date_test_defmt("ddmmyy", "21254");
     139            0 :         date_test_defmt("ddmmyy", "    21254    ");
     140              : 
     141              :         /* ECPG_INFORMIX_BAD_DAY */
     142            0 :         date_test_defmt("ddmmyy", "320494");
     143              : 
     144              :         /* ECPG_INFORMIX_BAD_MONTH */
     145            0 :         date_test_defmt("mm-yyyy-dd", "13-1993-21");
     146              : 
     147              :         /* ECPG_INFORMIX_BAD_YEAR */
     148              :         /* ??? */
     149              : 
     150            0 :         return 0;
     151            0 : }
     152              : 
     153              : static void
     154            0 : check_return(int ret)
     155              : {
     156            0 :         switch(ret)
     157              :         {
     158              :                 case ECPG_INFORMIX_ENOTDMY:
     159            0 :                         printf("(ECPG_INFORMIX_ENOTDMY)");
     160            0 :                         break;
     161              :                 case ECPG_INFORMIX_ENOSHORTDATE:
     162            0 :                         printf("(ECPG_INFORMIX_ENOSHORTDATE)");
     163            0 :                         break;
     164              :                 case ECPG_INFORMIX_BAD_DAY:
     165            0 :                         printf("(ECPG_INFORMIX_BAD_DAY)");
     166            0 :                         break;
     167              :                 case ECPG_INFORMIX_BAD_MONTH:
     168            0 :                         printf("(ECPG_INFORMIX_BAD_MONTH)");
     169            0 :                         break;
     170              :                 default:
     171            0 :                         printf("(unknown ret: %d)", ret);
     172            0 :                         break;
     173              :         }
     174            0 :         printf("\n");
     175            0 : }
        

Generated by: LCOV version 2.3.2-1