LCOV - code coverage report
Current view: top level - generated/include/ad/physics - DurationValidInputRange.hpp (source / functions) Hit Total Coverage
Test: ad_physics Lines: 14 14 100.0 %
Date: 2022-10-04 09:47:07 Functions: 1 1 100.0 %
Branches: 21 32 65.6 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * ----------------- BEGIN LICENSE BLOCK ---------------------------------
       3                 :            :  *
       4                 :            :  * Copyright (C) 2018-2020 Intel Corporation
       5                 :            :  *
       6                 :            :  * SPDX-License-Identifier: MIT
       7                 :            :  *
       8                 :            :  * ----------------- END LICENSE BLOCK -----------------------------------
       9                 :            :  */
      10                 :            : 
      11                 :            : /**
      12                 :            :  * Generated file
      13                 :            :  * @file
      14                 :            :  *
      15                 :            :  * Generator Version : 11.0.0-1997
      16                 :            :  */
      17                 :            : 
      18                 :            : #pragma once
      19                 :            : 
      20                 :            : #include <cmath>
      21                 :            : #include <limits>
      22                 :            : #include "ad/physics/Duration.hpp"
      23                 :            : #include "spdlog/fmt/ostr.h"
      24                 :            : #include "spdlog/spdlog.h"
      25                 :            : 
      26                 :            : /*!
      27                 :            :  * \brief check if the given Duration is within valid input range
      28                 :            :  *
      29                 :            :  * \param[in] input the Duration as an input value
      30                 :            :  * \param[in] logErrors enables error logging
      31                 :            :  *
      32                 :            :  * \returns \c true if Duration is considered to be within the specified input range
      33                 :            :  *
      34                 :            :  * \note the specified input range is defined by
      35                 :            :  *       std::numeric_limits<::ad::physics::Duration>::lowest() <= \c input <=
      36                 :            :  * std::numeric_limits<::ad::physics::Duration>::max()
      37                 :            :  *       0. <= \c input <= 1e6
      38                 :            :  */
      39                 :         11 : inline bool withinValidInputRange(::ad::physics::Duration const &input, bool const logErrors = true)
      40                 :            : {
      41                 :            :   // check for generic numeric limits of the type
      42   [ +  -  +  - ]:         18 :   bool inValidInputRange = input.isValid() && (std::numeric_limits<::ad::physics::Duration>::lowest() <= input)
      43   [ +  +  +  -  :         18 :     && (input <= std::numeric_limits<::ad::physics::Duration>::max());
                   +  - ]
      44   [ +  +  +  - ]:         11 :   if (!inValidInputRange && logErrors)
      45                 :            :   {
      46         [ +  - ]:          4 :     spdlog::error("withinValidInputRange(::ad::physics::Duration)>> {} out of numerical limits [{}, {}]",
      47                 :            :                   input,
      48                 :          4 :                   std::numeric_limits<::ad::physics::Duration>::lowest(),
      49                 :          8 :                   std::numeric_limits<::ad::physics::Duration>::max()); // LCOV_EXCL_BR_LINE
      50                 :            :   }
      51                 :            :   // check for individual input range
      52         [ +  + ]:         11 :   if (inValidInputRange)
      53                 :            :   {
      54   [ +  -  +  +  :          7 :     inValidInputRange = (::ad::physics::Duration(0.) <= input) && (input <= ::ad::physics::Duration(1e6));
             +  -  +  - ]
      55   [ +  +  +  - ]:          7 :     if (!inValidInputRange && logErrors)
      56                 :            :     {
      57         [ +  - ]:          3 :       spdlog::error("withinValidInputRange(::ad::physics::Duration)>> {} out of valid input range [{}, {}]",
      58                 :            :                     input,
      59                 :          3 :                     ::ad::physics::Duration(0.),
      60                 :          6 :                     ::ad::physics::Duration(1e6)); // LCOV_EXCL_BR_LINE
      61                 :            :     }
      62                 :            :   }
      63                 :         11 :   return inValidInputRange;
      64                 :            : }

Generated by: LCOV version 1.14