Quinoa all test code coverage report
Current view: top level - UnitTest - TUTUtil.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 10 10 100.0 %
Date: 2024-04-29 14:59:56 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 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                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Utilities for unit testing with the Template Unit Test library
       9                 :            :   \details   Utilities for unit testing with the Template Unit Test library.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef TUTUtil_h
      13                 :            : #define TUTUtil_h
      14                 :            : 
      15                 :            : #include <limits>
      16                 :            : #include <algorithm>
      17                 :            : 
      18                 :            : #include "NoWarning/tut.hpp"
      19                 :            : 
      20                 :            : namespace unittest {
      21                 :            : 
      22                 :            : //! \brief Ensure equality of all element of a vector of Ts (e.g., floating
      23                 :            : //!   point numbers) up to some precision
      24                 :            : //! \param[in] msg Message to output if the vectors are not equal
      25                 :            : //! \param[in] a First vector to compare
      26                 :            : //! \param[in] b Second vector to compare
      27                 :            : //! \param[in] prec Optional precision
      28                 :            : template< typename T >
      29                 :        279 : void veceq( const std::string& msg,
      30                 :            :             const std::vector< T >& a,
      31                 :            :             const std::vector< T >& b,
      32                 :            :             tk::real prec = std::numeric_limits< T >::epsilon() )
      33                 :            : {
      34                 :        279 :   std::equal( a.cbegin(), a.cend(), b.cbegin(),
      35                 :       2287 :               [ &msg, &prec ]( T s, T d )
      36                 :       2287 :               { tut::ensure_equals( msg, s, d, prec ); return true; } );
      37                 :        279 : }
      38                 :            : 
      39                 :            : //! \brief Ensure equality of all element of a array of Ts (e.g., floating
      40                 :            : //!   point numbers) up to some precision
      41                 :            : //! \param[in] msg Message to output if the arrays are not equal
      42                 :            : //! \param[in] a First array to compare
      43                 :            : //! \param[in] b Second array to compare
      44                 :            : //! \param[in] prec Optional precision
      45                 :            : template< typename T, std::size_t N >
      46                 :         32 : void veceq( const std::string& msg,
      47                 :            :             const std::array< T, N >& a,
      48                 :            :             const std::array< T, N >& b,
      49                 :            :             tk::real prec = std::numeric_limits< T >::epsilon() )
      50                 :            : {
      51                 :         32 :   std::equal( a.cbegin(), a.cend(), b.cbegin(),
      52                 :        112 :               [ &msg, &prec ]( T s, T d )
      53                 :        112 :               { tut::ensure_equals( msg, s, d, prec ); return true; } );
      54                 :         32 : }
      55                 :            : 
      56                 :            : } // unittest::
      57                 :            : 
      58                 :            : #endif // TUTUtil_h

Generated by: LCOV version 1.14