LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/pgtypeslib - num_test.pgc (source / functions) Coverage Total Hit UBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 100.0 % 69 69 69
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20250907-010129-baseline Branches: 50.0 % 14 7 7 7
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(360..) days: 100.0 % 69 69 69
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(360..) days: 50.0 % 14 7 7 7

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : #include <stdio.h>
                                  2                 :                : #include <stdlib.h>
                                  3                 :                : #include <pgtypes_numeric.h>
                                  4                 :                : #include <decimal.h>
                                  5                 :                : 
                                  6                 :                : exec sql include ../regression;
                                  7                 :                : 
                                  8                 :                : exec sql include ../printf_hack;
                                  9                 :                : 
                                 10                 :                : 
                                 11                 :                : int
 6976 meskes@postgresql.or       12                 :CBC           1 : main(void)
                                 13                 :                : {
                                 14                 :              1 :     char *text="error\n";
                                 15                 :                :     numeric *value1, *value2, *res;
                                 16                 :                :     exec sql begin declare section;
                                 17                 :                :         numeric(14,7) *des;
                                 18                 :                :         /* = {0, 0, 0, 0, 0, NULL, NULL} ; */
                                 19                 :                :     exec sql end declare section;
                                 20                 :                :     double d;
                                 21                 :                :     long l1, l2;
                                 22                 :                :     int i, min, max;
                                 23                 :                : 
                                 24                 :              1 :     ECPGdebug(1, stderr);
                                 25                 :                :     exec sql whenever sqlerror do sqlprint();
                                 26                 :                : 
                                 27                 :              1 :     exec sql connect to REGRESSDB1;
                                 28         [ -  + ]:              1 : 
                                 29                 :              1 :     exec sql set autocommit = off;
                                 30         [ -  + ]:              1 :     exec sql create table test (text char(5), num numeric(14,7));
                                 31         [ -  + ]:              1 : 
                                 32                 :              1 :     value1 = PGTYPESnumeric_new();
                                 33                 :              1 :     PGTYPESnumeric_from_int(1407, value1);
                                 34                 :              1 :     text = PGTYPESnumeric_to_asc(value1, -1);
 6971                            35                 :              1 :     printf("from int = %s\n", text);
 2638 tmunro@postgresql.or       36                 :              1 :     PGTYPESchar_free(text);
 6976 meskes@postgresql.or       37                 :              1 :     PGTYPESnumeric_free(value1);
                                 38                 :                : 
                                 39                 :              1 :     value1 = PGTYPESnumeric_from_asc("2369.7", NULL);
                                 40                 :              1 :     value2 = PGTYPESnumeric_from_asc("10.0", NULL);
                                 41                 :              1 :     res = PGTYPESnumeric_new();
                                 42                 :              1 :     PGTYPESnumeric_add(value1, value2, res);
                                 43                 :              1 :     text = PGTYPESnumeric_to_asc(res, -1);
                                 44                 :              1 :     printf("add = %s\n", text);
 2638 tmunro@postgresql.or       45                 :              1 :     PGTYPESchar_free(text);
                                 46                 :                : 
 6976 meskes@postgresql.or       47                 :              1 :     PGTYPESnumeric_sub(res, value2, res);
                                 48                 :              1 :     text = PGTYPESnumeric_to_asc(res, -1);
                                 49                 :              1 :     printf("sub = %s\n", text);
 2638 tmunro@postgresql.or       50                 :              1 :     PGTYPESchar_free(text);
 6976 meskes@postgresql.or       51                 :              1 :     PGTYPESnumeric_free(value2);
                                 52                 :                : 
                                 53                 :              1 :     des = PGTYPESnumeric_new();
                                 54                 :              1 :     PGTYPESnumeric_copy(res, des);
                                 55                 :              1 :     exec sql insert into test (text, num) values ('test', :des);
                                 56         [ -  + ]:              1 : 
                                 57                 :              1 :     value2 = PGTYPESnumeric_from_asc("2369.7", NULL);
                                 58                 :              1 :     PGTYPESnumeric_mul(value1, value2, res);
                                 59                 :              1 :     PGTYPESnumeric_free(value2);
                                 60                 :                : 
                                 61                 :              1 :     exec sql select num into :des from test where text = 'test';
                                 62         [ -  + ]:              1 : 
                                 63                 :              1 :     PGTYPESnumeric_mul(res, des, res);
                                 64                 :              1 :     text = PGTYPESnumeric_to_asc(res, -1);
                                 65                 :              1 :     printf("mul = %s\n", text);
 2638 tmunro@postgresql.or       66                 :              1 :     PGTYPESchar_free(text);
 6976 meskes@postgresql.or       67                 :              1 :     PGTYPESnumeric_free(des);
                                 68                 :                : 
                                 69                 :              1 :     value2 = PGTYPESnumeric_from_asc("10000", NULL);
                                 70                 :              1 :     PGTYPESnumeric_div(res, value2, res);
                                 71                 :              1 :     text = PGTYPESnumeric_to_asc(res, -1);
                                 72                 :              1 :     PGTYPESnumeric_to_double(res, &d);
 2522 tgl@sss.pgh.pa.us          73                 :              1 :     printf("div = %s ", text);
                                 74                 :              1 :     print_double(d);
                                 75                 :              1 :     printf("\n");
                                 76                 :                : 
 5500 meskes@postgresql.or       77                 :              1 :     PGTYPESnumeric_free(value1);
                                 78                 :              1 :     PGTYPESnumeric_free(value2);
                                 79                 :                : 
 6971                            80                 :              1 :     value1 = PGTYPESnumeric_from_asc("2E7", NULL);
                                 81                 :              1 :     value2 = PGTYPESnumeric_from_asc("14", NULL);
                                 82                 :              1 :     i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
                                 83                 :              1 :     printf("to long(%d) = %ld %ld\n", i, l1, l2);
                                 84                 :                : 
 2638 tmunro@postgresql.or       85                 :              1 :     PGTYPESchar_free(text);
 6976 meskes@postgresql.or       86                 :              1 :     PGTYPESnumeric_free(value1);
                                 87                 :              1 :     PGTYPESnumeric_free(value2);
                                 88                 :              1 :     PGTYPESnumeric_free(res);
                                 89                 :                : 
                                 90                 :                :     /* check conversion of numeric to int */
 1500 john.naylor@postgres       91                 :              1 :     value1 = PGTYPESnumeric_from_asc("-2147483648", NULL);
                                 92                 :              1 :     PGTYPESnumeric_to_int(value1, &min);
                                 93                 :              1 :     printf("min int = %d\n", min);
                                 94                 :              1 :     PGTYPESnumeric_free(value1);
                                 95                 :                : 
                                 96                 :              1 :     value2 = PGTYPESnumeric_from_asc("2147483647", NULL);
                                 97                 :              1 :     PGTYPESnumeric_to_int(value2, &max);
                                 98                 :              1 :     printf("max int = %d\n", max);
                                 99                 :              1 :     PGTYPESnumeric_free(value2);
                                100                 :                : 
 6976 meskes@postgresql.or      101                 :              1 :     exec sql rollback;
                                102         [ -  + ]:              1 :     exec sql disconnect;
                                103         [ -  + ]:              1 : 
 2943 peter_e@gmx.net           104                 :              1 :     return 0;
                                105                 :                : }
        

Generated by: LCOV version 2.4-beta