Xyst test code coverage report
Current view: top level - UnitTest - TUTUtil.hpp Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 100.0 % 6 6
Test Date: 2025-08-13 22:18:46 Functions: - 0 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 50.0 % 496 248

             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-2025 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                 :             : #if defined(STRICT_GNUC)
      24                 :             :   #pragma GCC diagnostic push
      25                 :             :   #pragma GCC diagnostic ignored "-Wunused-result"
      26                 :             : #endif
      27                 :             : 
      28                 :             : //! \brief Ensure equality of all element of a vector of Ts (e.g., floating
      29                 :             : //!   point numbers) up to some precision
      30                 :             : //! \param[in] msg Message to output if the vectors are not equal
      31                 :             : //! \param[in] a First vector to compare
      32                 :             : //! \param[in] b Second vector to compare
      33                 :             : //! \param[in] prec Optional precision
      34                 :             : template< typename T >
      35                 :             : void veceq( const std::string& msg,
      36                 :             :             const std::vector< T >& a,
      37                 :             :             const std::vector< T >& b,
      38                 :             :             tk::real prec = std::numeric_limits< T >::epsilon() )
      39                 :             : {
      40 [ +  - ][ +  - ]:         247 :   std::equal( a.cbegin(), a.cend(), b.cbegin(),
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      41                 :             :               [ &msg, &prec ]( T s, T d )
      42                 :        2203 :               { tut::ensure_equals( msg, s, d, prec ); return true; } );
      43                 :         247 : }
      44                 :             : 
      45                 :             : //! \brief Ensure equality of all element of a array of Ts (e.g., floating
      46                 :             : //!   point numbers) up to some precision
      47                 :             : //! \param[in] msg Message to output if the arrays are not equal
      48                 :             : //! \param[in] a First array to compare
      49                 :             : //! \param[in] b Second array to compare
      50                 :             : //! \param[in] prec Optional precision
      51                 :             : template< typename T, std::size_t N >
      52                 :             : void veceq( const std::string& msg,
      53                 :             :             const std::array< T, N >& a,
      54                 :             :             const std::array< T, N >& b,
      55                 :             :             tk::real prec = std::numeric_limits< T >::epsilon() )
      56                 :             : {
      57 [ +  - ][ +  - ]:           4 :   std::equal( a.cbegin(), a.cend(), b.cbegin(),
         [ +  - ][ +  - ]
      58                 :             :               [ &msg, &prec ]( T s, T d )
      59                 :          16 :               { tut::ensure_equals( msg, s, d, prec ); return true; } );
      60                 :           4 : }
      61                 :             : 
      62                 :             : #if defined(STRICT_GNUC)
      63                 :             :   #pragma GCC diagnostic pop
      64                 :             : #endif
      65                 :             : 
      66                 :             : } // unittest::
      67                 :             : 
      68                 :             : #endif // TUTUtil_h
        

Generated by: LCOV version 2.0-1