Xyst test code coverage report
Current view: top level - Inciter/AMR - edge.hpp (source / functions) Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 73.5 % 34 25
Test Date: 2025-08-13 22:46:33 Functions: 88.9 % 9 8
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 57.1 % 14 8

             Branch data     Line data    Source code
       1                 :             : #ifndef AMR_edge_t_h
       2                 :             : #define AMR_edge_t_h
       3                 :             : 
       4                 :             : #include <iostream>
       5                 :             : #include <stddef.h>
       6                 :             : #include <array>
       7                 :             : #include <algorithm>
       8                 :             : 
       9                 :             : namespace AMR {
      10                 :             : 
      11                 :             : class edge_t {
      12                 :             :     using edge_ = std::array< std::size_t, 2 >;
      13                 :             :     private:
      14                 :             :         edge_ data;
      15                 :             :         friend std::ostream& operator<<(std::ostream&, const edge_t&);
      16                 :             : 
      17                 :             :     public:
      18                 :     5883570 :         edge_& get_data() {
      19                 :     5883570 :             return data;
      20                 :             :         }
      21                 :             : 
      22                 :  1851360048 :         const edge_& get_data() const {
      23                 :  1851360048 :             return data;
      24                 :             :         }
      25                 :             : 
      26                 :             :         // Constructors
      27                 :    16485199 :         edge_t()
      28                 :    16485199 :         {
      29                 :    16485199 :         }
      30                 :             : 
      31                 :    13597035 :         edge_t(size_t A, size_t B) : data( {{std::min(A,B), std::max(A,B)}} )
      32                 :             :         {
      33                 :    13597035 :         }
      34                 :             : 
      35                 :     1162278 :         explicit edge_t( edge_ e ) : data( std::move(e) ) {}
      36                 :             : 
      37                 :             :         // Operators
      38                 :             :             // Piggy back underlying edge_ type where possible
      39                 :           0 :         bool operator==(const edge_t& rhs) const
      40                 :             :         {
      41                 :             :           // ensure entries of rhs and this are in ascending order
      42                 :           0 :           auto this_copy = this->data;
      43                 :           0 :           this_copy[0] = std::min(this->data[0], this->data[1]);
      44                 :           0 :           this_copy[1] = std::max(this->data[0], this->data[1]);
      45                 :             :           std::array< std::size_t, 2 > rhs_copy;
      46                 :           0 :           rhs_copy[0] = std::min(rhs.get_data()[0], rhs.get_data()[1]);
      47                 :           0 :           rhs_copy[1] = std::max(rhs.get_data()[0], rhs.get_data()[1]);
      48                 :             : 
      49 [ -  - ][ -  - ]:           0 :           if (this_copy[0] == rhs_copy[0] && this_copy[1] == rhs_copy[1])
                 [ -  - ]
      50                 :           0 :             return true;
      51                 :             :           else
      52                 :           0 :             return false;
      53                 :             :         }
      54                 :             :         //bool operator>(const edge_t& rhs) const
      55                 :             :         //{
      56                 :             :         //  return (data > rhs.get_data());
      57                 :             :         //}
      58                 :   462839231 :         bool operator<(const edge_t& rhs) const
      59                 :             :         {
      60                 :             :           // ensure entries of rhs and this are in ascending order
      61                 :   462839231 :           auto this_copy = this->data;
      62                 :   462839231 :           this_copy[0] = std::min(this->data[0], this->data[1]);
      63                 :   462839231 :           this_copy[1] = std::max(this->data[0], this->data[1]);
      64                 :             :           std::array< std::size_t, 2 > rhs_copy;
      65                 :   462839231 :           rhs_copy[0] = std::min(rhs.get_data()[0], rhs.get_data()[1]);
      66                 :   462839231 :           rhs_copy[1] = std::max(rhs.get_data()[0], rhs.get_data()[1]);
      67                 :             : 
      68         [ +  + ]:   462839231 :           if (this_copy[0] < rhs_copy[0])
      69                 :   165189378 :             return true;
      70 [ +  + ][ +  + ]:   297649853 :           else if (this_copy[0] == rhs_copy[0] && this_copy[1] < rhs_copy[1])
                 [ +  + ]
      71                 :    61937781 :             return true;
      72                 :             :           else
      73                 :   235712072 :             return false;
      74                 :             :         }
      75                 :             : 
      76                 :     7677668 :         size_t first() const
      77                 :             :         {
      78                 :     7677668 :             return data[0];
      79                 :             :         }
      80                 :     7677668 :         size_t second() const
      81                 :             :         {
      82                 :     7677668 :             return data[1];
      83                 :             :         }
      84                 :             : 
      85                 :             :         void replace(size_t new_id, size_t old_id)
      86                 :             :         {
      87                 :             :             if (data[0] == old_id)
      88                 :             :             {
      89                 :             :                 data[0] = new_id;
      90                 :             :             }
      91                 :             : 
      92                 :             :             if (data[1] == old_id)
      93                 :             :             {
      94                 :             :                 data[1] = new_id;
      95                 :             :             }
      96                 :             :         }
      97                 :             : 
      98                 :             : };
      99                 :             : 
     100                 :             : }  // AMR::
     101                 :             : 
     102                 :             : #endif
        

Generated by: LCOV version 2.0-1