Xyst test code coverage report
Current view: top level - UnitTest - TUTUtil.hpp (source / functions) Hit Total Coverage
Commit: 5689ba12dc66a776d3d75f1ee48cc7d78eaa18dc Lines: 8 8 100.0 %
Date: 2024-11-22 19:02:53 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 248 496 50.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/UnitTest/TUTUtil.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.,
       7                 :            :              2022-2024 J. Bakosi
       8                 :            :              All rights reserved. See the LICENSE file for details.
       9                 :            :   \brief     Utilities for unit testing with the Template Unit Test library
      10                 :            :   \details   Utilities for unit testing with the Template Unit Test library.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef TUTUtil_h
      14                 :            : #define TUTUtil_h
      15                 :            : 
      16                 :            : #include <limits>
      17                 :            : #include <algorithm>
      18                 :            : 
      19                 :            : #include "NoWarning/tut.hpp"
      20                 :            : 
      21                 :            : namespace unittest {
      22                 :            : 
      23                 :            : //! \brief Ensure equality of all element of a vector of Ts (e.g., floating
      24                 :            : //!   point numbers) up to some precision
      25                 :            : //! \param[in] msg Message to output if the vectors are not equal
      26                 :            : //! \param[in] a First vector to compare
      27                 :            : //! \param[in] b Second vector to compare
      28                 :            : //! \param[in] prec Optional precision
      29                 :            : template< typename T >
      30                 :            : void veceq( const std::string& msg,
      31                 :            :             const std::vector< T >& a,
      32                 :            :             const std::vector< T >& b,
      33                 :            :             tk::real prec = std::numeric_limits< T >::epsilon() )
      34                 :            : {
      35 [ +  - ][ +  - ]:        247 :   std::equal( a.cbegin(), a.cend(), b.cbegin(),
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      36                 :       2203 :               [ &msg, &prec ]( T s, T d )
      37                 :       2203 :               { tut::ensure_equals( msg, s, d, prec ); return true; } );
      38                 :        247 : }
      39                 :            : 
      40                 :            : //! \brief Ensure equality of all element of a array of Ts (e.g., floating
      41                 :            : //!   point numbers) up to some precision
      42                 :            : //! \param[in] msg Message to output if the arrays are not equal
      43                 :            : //! \param[in] a First array to compare
      44                 :            : //! \param[in] b Second array to compare
      45                 :            : //! \param[in] prec Optional precision
      46                 :            : template< typename T, std::size_t N >
      47                 :            : void veceq( const std::string& msg,
      48                 :            :             const std::array< T, N >& a,
      49                 :            :             const std::array< T, N >& b,
      50                 :            :             tk::real prec = std::numeric_limits< T >::epsilon() )
      51                 :            : {
      52 [ +  - ][ +  - ]:          4 :   std::equal( a.cbegin(), a.cend(), b.cbegin(),
         [ +  - ][ +  - ]
      53                 :         16 :               [ &msg, &prec ]( T s, T d )
      54                 :         16 :               { tut::ensure_equals( msg, s, d, prec ); return true; } );
      55                 :          4 : }
      56                 :            : 
      57                 :            : } // unittest::
      58                 :            : 
      59                 :            : #endif // TUTUtil_h

Generated by: LCOV version 1.16