Xyst test code coverage report
Current view: top level - Inciter/AMR - edge.hpp Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 77.8 % 9 7
Test Date: 2025-08-13 22:18:46 Functions: - 0 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 52.7 % 188 99

             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                 :             :         edge_& get_data() {
      19                 :             :             return data;
      20                 :             :         }
      21                 :             : 
      22                 :             :         const edge_& get_data() const {
      23                 :           0 :             return data;
      24                 :             :         }
      25                 :             : 
      26                 :             :         // Constructors
      27                 :             :         edge_t()
      28                 :     1480734 :         {
      29                 :             :         }
      30                 :             : 
      31 [ +  - ][ +  - ]:      387520 :         edge_t(size_t A, size_t B) : data( {{std::min(A,B), std::max(A,B)}} )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      32                 :             :         {
      33                 :             :         }
      34                 :             : 
      35                 :     1162278 :         explicit edge_t( edge_ e ) : data( std::move(e) ) {}
      36                 :             : 
      37                 :             :         // Operators
      38                 :             :             // Piggy back underlying edge_ type where possible
      39                 :             :         bool operator==(const edge_t& rhs) const
      40                 :             :         {
      41                 :             :           // ensure entries of rhs and this are in ascending order
      42                 :             :           auto this_copy = this->data;
      43                 :             :           this_copy[0] = std::min(this->data[0], this->data[1]);
      44                 :             :           this_copy[1] = std::max(this->data[0], this->data[1]);
      45                 :             :           std::array< std::size_t, 2 > rhs_copy;
      46                 :             :           rhs_copy[0] = std::min(rhs.get_data()[0], rhs.get_data()[1]);
      47                 :             :           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                 :             :             return true;
      51                 :             :           else
      52                 :             :             return false;
      53                 :             :         }
      54                 :             :         //bool operator>(const edge_t& rhs) const
      55                 :             :         //{
      56                 :             :         //  return (data > rhs.get_data());
      57                 :             :         //}
      58                 :             :         bool operator<(const edge_t& rhs) const
      59                 :             :         {
      60                 :             :           // ensure entries of rhs and this are in ascending order
      61                 :             :           auto this_copy = this->data;
      62                 :             :           this_copy[0] = std::min(this->data[0], this->data[1]);
      63                 :             :           this_copy[1] = std::max(this->data[0], this->data[1]);
      64                 :             :           std::array< std::size_t, 2 > rhs_copy;
      65                 :             :           rhs_copy[0] = std::min(rhs.get_data()[0], rhs.get_data()[1]);
      66                 :             :           rhs_copy[1] = std::max(rhs.get_data()[0], rhs.get_data()[1]);
      67                 :             : 
      68 [ -  + ][ +  + ]:   356884951 :           if (this_copy[0] < rhs_copy[0])
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  + ]
         [ +  + ][ +  + ]
         [ +  - ][ +  + ]
         [ +  + ][ -  - ]
         [ -  - ][ +  + ]
         [ +  - ][ +  + ]
         [ +  + ][ +  + ]
         [ -  - ][ -  - ]
         [ +  + ][ +  + ]
      69                 :             :             return true;
      70 [ +  + ][ -  + ]:   228566313 :           else if (this_copy[0] == rhs_copy[0] && this_copy[1] < rhs_copy[1])
         [ +  - ][ +  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  - ][ +  - ]
         [ +  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  - ]
         [ +  + ][ -  + ]
         [ +  + ][ +  + ]
         [ +  - ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  + ]
         [ +  + ][ +  - ]
         [ -  + ][ +  - ]
         [ +  + ][ +  - ]
                 [ +  - ]
      71                 :             :             return true;
      72                 :             :           else
      73                 :             :             return false;
      74                 :             :         }
      75                 :             : 
      76                 :             :         size_t first() const
      77                 :             :         {
      78         [ -  - ]:         392 :             return data[0];
      79                 :             :         }
      80                 :             :         size_t second() const
      81                 :             :         {
      82 [ -  - ][ -  - ]:      163352 :             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