LCOV - code coverage report
Current view: top level - include/pairinteraction/utils - Range.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 14 78.6 %
Date: 2026-08-14 15:36:24 Functions: 8 8 100.0 %

          Line data    Source code
       1             : // SPDX-FileCopyrightText: 2024 PairInteraction Developers
       2             : // SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4             : #pragma once
       5             : 
       6             : #include "pairinteraction/utils/traits.hpp"
       7             : 
       8             : namespace pairinteraction {
       9             : template <typename Sortable>
      10             : class Range {
      11             :     static_assert(traits::OpTraits<Sortable>::has_less_v);
      12             : 
      13             : public:
      14        4700 :     Range() = default;
      15       58799 :     Range(Sortable min, Sortable max) : _min(min), _max(max), _is_finite(true) {
      16       58799 :         if (max < min) {
      17           0 :             throw std::invalid_argument("It must be max >= min.");
      18             :         }
      19       58799 :     }
      20     7236065 :     Sortable min() const {
      21     7236065 :         if (!_is_finite) {
      22           0 :             throw std::runtime_error("The range is infinite.");
      23             :         }
      24     7236065 :         return _min;
      25             :     }
      26    14062138 :     Sortable max() const {
      27    14062138 :         if (!_is_finite) {
      28           0 :             throw std::runtime_error("The range is infinite.");
      29             :         }
      30    14062138 :         return _max;
      31             :     }
      32     5995674 :     bool is_finite() const { return _is_finite; }
      33             : 
      34             : private:
      35             :     Sortable _min{};
      36             :     Sortable _max{};
      37             :     bool _is_finite{false};
      38             : };
      39             : } // namespace pairinteraction

Generated by: LCOV version 1.16