Quinoa all test code coverage report
Current view: top level - Base - Types.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 15 15 100.0 %
Date: 2024-04-29 14:42:33 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 17 28 60.7 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Base/Types.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     Toolkit-level type definitions
       9                 :            :   \details   Toolkit-level type definitions
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef Types_h
      13                 :            : #define Types_h
      14                 :            : 
      15                 :            : #include <cstddef>
      16                 :            : #include <string>
      17                 :            : #include <optional>
      18                 :            : 
      19                 :            : namespace tk {
      20                 :            : 
      21                 :            : //! Real number type used throughout the whole code.
      22                 :            : // TODO Test with single precision and possibly others.
      23                 :            : using real = double;
      24                 :            : 
      25                 :            : //! uint type used throughout the whole code.
      26                 :            : using ncomp_t = std::size_t;
      27                 :            : 
      28                 :            : //! Struct for storing info
      29                 :            : struct info_t {
      30                 :            :   std::string kw;
      31                 :            :   std::string sDescr;
      32                 :            :   std::string lDescr;
      33                 :            :   std::string tDescr;
      34                 :            : 
      35                 :            :   // constructor
      36                 :     314870 :   info_t(
      37                 :            :     std::string k,
      38                 :            :     std::string s,
      39                 :            :     std::string l,
      40                 :     314870 :     std::string t ) :
      41                 :            :     kw(k),
      42                 :            :     sDescr(s),
      43                 :            :     lDescr(l),
      44 [ +  - ][ +  - ]:     944610 :     tDescr(t)
                 [ +  - ]
      45                 :     314870 :     {}
      46                 :            : 
      47                 :            :   // Accessors
      48                 :            :   std::string keyword() const {return kw;}
      49                 :            :   std::string shortDescription() const {return sDescr;}
      50                 :            :   std::string longDescription() const {return lDescr;}
      51                 :            :   std::string typeDescription() const {return tDescr;}
      52                 :            : };
      53                 :            : 
      54                 :            : //! Struct for storing keyword in the input deck
      55                 :     933658 : struct entry_t {
      56                 :            :   info_t info;
      57                 :            : 
      58                 :            :   // constructor
      59                 :     314870 :   entry_t(
      60                 :            :     std::string kw,
      61                 :            :     std::string sDescr,
      62                 :            :     std::string lDescr,
      63                 :     314870 :     std::string tDescr="" ) :
      64 [ +  - ][ +  + ]:    1564767 :     info(kw, sDescr, lDescr, tDescr)
         [ +  - ][ +  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
      65                 :     314870 :     {}
      66                 :            : 
      67                 :            :   //! Accessor to keyword as std::string
      68                 :            :   //! \return Keyword as std::string
      69                 :     309394 :   const std::string string() const { return info.keyword(); }
      70                 :            : 
      71                 :            :   //! Accessor to required short name of a keyword
      72                 :            :   //! \return Name of keyword as std::string
      73                 :            :   const std::string name() const { return info.keyword(); }
      74                 :            : 
      75                 :            :   //! Accessor to required short description of a keyword
      76                 :            :   //! \return Short help as std::string
      77                 :            :   const std::string shortDescription() const { return info.shortDescription(); }
      78                 :            : 
      79                 :            :   //! Accessor to required long description of a keyword
      80                 :            :   //! \return Long help as std::string
      81                 :            :   const std::string longDescription() const { return info.longDescription(); }
      82                 :            : 
      83                 :            :   //! Alias accessor for keyword
      84                 :            :   //! \return Null. This is a punt to fit in the existing HelpFactory
      85                 :            :   //!   infrastructure; needs to be removed.
      86                 :            :   const std::optional< std::string > alias() const { return std::nullopt; }
      87                 :            : 
      88                 :            :   //! Expected type description accessor for keyword
      89                 :            :   //! \return Type description for keyword
      90                 :     309394 :   const std::optional< std::string > expt() const {
      91         [ +  + ]:     309394 :     if (!info.typeDescription().empty())
      92                 :     203981 :       return info.typeDescription();
      93                 :            :     else
      94                 :     105413 :       return std::nullopt;
      95                 :            :   }
      96                 :            : 
      97                 :            :   //! Expected lower bound accessor for a keyword
      98                 :            :   //! \return Null.
      99                 :            :   const std::optional< std::string > lower() const { return std::nullopt; }
     100                 :            : 
     101                 :            :   //! Expected upper bound accessor for a keyword
     102                 :            :   //! \return Null.
     103                 :            :   const std::optional< std::string > upper() const { return std::nullopt; }
     104                 :            : 
     105                 :            :   //! Expected choices description accessor for a keyword
     106                 :            :   //! \return Null.
     107                 :            :   const std::optional< std::string > choices() const { return std::nullopt; }
     108                 :            : 
     109                 :            :   //! \brief Less-than operator for ordering, used by, e.g., std::set::insert
     110                 :            :   //! \param[in] en entry_t to compare
     111                 :            :   //! \return Boolean indicating if en is less than 'this'
     112                 :            :   bool operator< ( const entry_t& en ) const {
     113 [ +  + ][ +  + ]:    2742107 :     if (info.kw < en.info.kw)
                 [ +  + ]
     114                 :            :       return true;
     115                 :            :     else
     116                 :            :       return false;
     117                 :            :   }
     118                 :            : };
     119                 :            : 
     120                 :            : } // tk::
     121                 :            : 
     122                 :            : #endif // Types_h

Generated by: LCOV version 1.14