LCOV - differential code coverage report
Current view: top level - src/test/modules/test_cplusplusext - test_cplusplusext.cpp (source / functions) Coverage Total Hit UNC GNC
Current: 0e5ff9b9b45a657aea12440478dc002e9b01f138 vs 0123ce131fca454009439dfa3b2266d1d40737d7 Lines: 100.0 % 20 20 20
Current Date: 2026-03-14 14:10:32 -0400 Functions: 100.0 % 3 3 3
Baseline: lcov-20260315-024220-baseline Branches: 72.0 % 25 18 7 18
Baseline Date: 2026-03-14 15:27:56 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(1,7] days: 100.0 % 2 2 2
(7,30] days: 100.0 % 12 12 12
(30,360] days: 100.0 % 6 6 6
Function coverage date bins:
(30,360] days: 100.0 % 3 3 3
Branch coverage date bins:
(7,30] days: 72.0 % 25 18 7 18

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*--------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * test_cplusplusext.cpp
                                  4                 :                :  *      Test that PostgreSQL headers compile with a C++ compiler.
                                  5                 :                :  *
                                  6                 :                :  * This file is compiled with a C++ compiler to verify that PostgreSQL
                                  7                 :                :  * headers remain compatible with C++ extensions.
                                  8                 :                :  *
                                  9                 :                :  * Copyright (c) 2025-2026, PostgreSQL Global Development Group
                                 10                 :                :  *
                                 11                 :                :  * IDENTIFICATION
                                 12                 :                :  *      src/test/modules/test_cplusplusext/test_cplusplusext.cpp
                                 13                 :                :  *
                                 14                 :                :  * -------------------------------------------------------------------------
                                 15                 :                :  */
                                 16                 :                : 
                                 17                 :                : extern "C" {
                                 18                 :                : #include "postgres.h"
                                 19                 :                : #include "fmgr.h"
                                 20                 :                : #include "nodes/pg_list.h"
                                 21                 :                : #include "nodes/primnodes.h"
                                 22                 :                : 
   54 peter@eisentraut.org       23                 :GNC           1 : PG_MODULE_MAGIC;
                                 24                 :                : 
                                 25                 :              2 : PG_FUNCTION_INFO_V1(test_cplusplus_add);
                                 26                 :                : }
                                 27                 :                : 
                                 28                 :                : StaticAssertDecl(sizeof(int32) == 4, "int32 should be 4 bytes");
                                 29                 :                : 
                                 30                 :                : /*
                                 31                 :                :  * Simple function that returns the sum of two integers.  This verifies that
                                 32                 :                :  * C++ extension modules can be loaded and called correctly at runtime.
                                 33                 :                :  */
                                 34                 :                : extern "C" Datum
                                 35                 :              1 : test_cplusplus_add(PG_FUNCTION_ARGS)
                                 36                 :                : {
                                 37                 :              1 :     int32       a = PG_GETARG_INT32(0);
                                 38                 :              1 :     int32       b = PG_GETARG_INT32(1);
   26                            39                 :              1 :     RangeTblRef *node = makeNode(RangeTblRef);
    2                            40                 :              1 :     const RangeTblRef *nodec = node;
                                 41                 :              1 :     RangeTblRef *copy = copyObject(nodec);
   26                            42                 :              1 :     List       *list = list_make1(node);
                                 43                 :                : 
                                 44   [ +  -  +  +  :              3 :     foreach_ptr(RangeTblRef, rtr, list)
                                        +  +  +  + ]
                                 45                 :                :     {
                                 46                 :                :         (void) rtr;
                                 47                 :                :     }
                                 48                 :                : 
                                 49   [ +  -  +  +  :              3 :     foreach_node(RangeTblRef, rtr, list)
                                     +  -  +  +  +  
                                                 + ]
                                 50                 :                :     {
                                 51                 :                :         (void) rtr;
                                 52                 :                :     }
                                 53                 :                : 
                                 54                 :                :     StaticAssertStmt(sizeof(int32) == 4, "int32 should be 4 bytes");
                                 55                 :                :     (void) StaticAssertExpr(sizeof(int64) == 8, "int64 should be 8 bytes");
                                 56                 :                : 
                                 57                 :              1 :     list_free(list);
                                 58                 :              1 :     pfree(node);
   13                            59                 :              1 :     pfree(copy);
                                 60                 :                : 
   20                            61      [ +  -  - ]:              1 :     switch (a)
                                 62                 :                :     {
                                 63                 :              1 :         case 1:
                                 64         [ -  + ]:              1 :             elog(DEBUG1, "1");
                                 65                 :                :             pg_fallthrough;
                                 66                 :                :         case 2:
                                 67         [ -  + ]:              1 :             elog(DEBUG1, "2");
                                 68                 :              1 :             break;
                                 69                 :                :     }
                                 70                 :                : 
   54                            71                 :              1 :     PG_RETURN_INT32(a + b);
                                 72                 :                : }
        

Generated by: LCOV version 2.4-beta