Quinoa all test code coverage report
Current view: top level - Inciter/AMR - edge.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 14 21 66.7 %
Date: 2024-04-22 13:03:21 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 60 104 57.7 %

           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         [ -  + ]:    1715485 :         {
      29                 :            :         }
      30                 :            : 
      31 [ +  + ][ +  - ]:   30457704 :         edge_t(size_t A, size_t B) : data( {{std::min(A,B), std::max(A,B)}} )
         [ +  - ][ -  + ]
         [ +  + ][ +  - ]
         [ +  + ][ +  - ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
                 [ +  + ]
      32                 :            :         {
      33                 :            :         }
      34                 :            : 
      35                 :    4194804 :         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 [ -  - ][ -  - ]:          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                 :            :             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                 :  927267912 :         bool operator<(const edge_t& rhs) const
      59                 :            :         {
      60                 :            :           // ensure entries of rhs and this are in ascending order
      61         [ -  + ]:  927267912 :           auto this_copy = this->data;
      62         [ +  - ]:  927267912 :           this_copy[0] = std::min(this->data[0], this->data[1]);
      63         [ -  + ]:  927267912 :           this_copy[1] = std::max(this->data[0], this->data[1]);
      64                 :            :           std::array< std::size_t, 2 > rhs_copy;
      65         [ +  - ]:  927267912 :           rhs_copy[0] = std::min(rhs.get_data()[0], rhs.get_data()[1]);
      66                 :  927267912 :           rhs_copy[1] = std::max(rhs.get_data()[0], rhs.get_data()[1]);
      67                 :            : 
      68         [ +  + ]:  927267912 :           if (this_copy[0] < rhs_copy[0])
      69                 :            :             return true;
      70 [ +  + ][ +  + ]:  604066463 :           else if (this_copy[0] == rhs_copy[0] && this_copy[1] < rhs_copy[1])
      71                 :            :             return true;
      72                 :            :           else
      73                 :  488209777 :             return false;
      74                 :            :         }
      75                 :            : 
      76                 :            :         size_t first() const
      77                 :            :         {
      78 [ -  - ][ -  - ]:     890258 :             return data[0];
      79                 :            :         }
      80                 :            :         size_t second() const
      81                 :            :         {
      82 [ -  - ][ -  - ]:     100876 :             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 1.14