differential code coverage report with master
Current view: top level - source/detail/cryptography - value_traits.hpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 24.4 % 45 11 34 11
Current Date: 2025-12-07 02:01:22 Functions: 100.0 % 2 2 2
Baseline: coverage_master.info Branches: 16.3 % 43 7 72 14
Baseline Date: 2025-12-07 02:01:21

             Branch data    TLA  Line data    Source code
       1                 :                : // Copyright (c) 2017-2022 Thomas Fussell
       2                 :                : // Copyright (c) 2024-2025 xlnt-community
       3                 :                : //
       4                 :                : // Permission is hereby granted, free of charge, to any person obtaining a copy
       5                 :                : // of this software and associated documentation files (the "Software"), to deal
       6                 :                : // in the Software without restriction, including without limitation the rights
       7                 :                : // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       8                 :                : // copies of the Software, and to permit persons to whom the Software is
       9                 :                : // furnished to do so, subject to the following conditions:
      10                 :                : //
      11                 :                : // The above copyright notice and this permission notice shall be included in
      12                 :                : // all copies or substantial portions of the Software.
      13                 :                : //
      14                 :                : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15                 :                : // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16                 :                : // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      17                 :                : // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      18                 :                : // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      19                 :                : // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      20                 :                : // THE SOFTWARE
      21                 :                : //
      22                 :                : // @license: http://www.opensource.org/licenses/mit-license.php
      23                 :                : // @author: see AUTHORS file
      24                 :                : 
      25                 :                : #pragma once
      26                 :                : 
      27                 :                : #include <string>
      28                 :                : 
      29                 :                : #include <detail/default_case.hpp>
      30                 :                : #include <detail/cryptography/hash.hpp>
      31                 :                : #include <detail/external/include_libstudxml.hpp>
      32                 :                : 
      33                 :                : namespace xml {
      34                 :                : 
      35                 :                : template <>
      36                 :                : struct value_traits<xlnt::detail::hash_algorithm>
      37                 :                : {
      38                 :CBC           6 :     static xlnt::detail::hash_algorithm parse(std::string hash_algorithm_string, const parser &)
      39                 :                :     {
      40         [ +  + ]:              6 :         if (hash_algorithm_string == "SHA1")
      41                 :              3 :             return xlnt::detail::hash_algorithm::sha1;
      42         [ -  + ]:              3 :         else if (hash_algorithm_string == "SHA256")
      43                 :UBC           0 :             return xlnt::detail::hash_algorithm::sha256;
      44         [ -  + ]:CBC           3 :         else if (hash_algorithm_string == "SHA384")
      45                 :UBC           0 :             return xlnt::detail::hash_algorithm::sha384;
      46         [ +  - ]:CBC           3 :         else if (hash_algorithm_string == "SHA512")
      47                 :              3 :             return xlnt::detail::hash_algorithm::sha512;
      48         [ #  # ]:UBC           0 :         else if (hash_algorithm_string == "MD5")
      49                 :              0 :             return xlnt::detail::hash_algorithm::md5;
      50         [ #  # ]:              0 :         else if (hash_algorithm_string == "MD4")
      51                 :              0 :             return xlnt::detail::hash_algorithm::md4;
      52         [ #  # ]:              0 :         else if (hash_algorithm_string == "MD2")
      53                 :              0 :             return xlnt::detail::hash_algorithm::md2;
      54         [ #  # ]:              0 :         else if (hash_algorithm_string == "Ripemd128")
      55                 :              0 :             return xlnt::detail::hash_algorithm::ripemd128;
      56         [ #  # ]:              0 :         else if (hash_algorithm_string == "Ripemd160")
      57                 :              0 :             return xlnt::detail::hash_algorithm::ripemd160;
      58         [ #  # ]:              0 :         else if (hash_algorithm_string == "Whirlpool")
      59                 :              0 :             return xlnt::detail::hash_algorithm::whirlpool;
      60            [ # ]:              0 :         default_case(xlnt::detail::hash_algorithm::sha1);
      61                 :                :     }
      62                 :                : 
      63                 :CBC           4 :     static std::string serialize(xlnt::detail::hash_algorithm algorithm, const serializer &)
      64                 :                :     {
      65   [ -  -  -  +  :              4 :         switch (algorithm)
          -  -  -  -  -  
                   -  - ]
      66                 :                :         {
      67                 :UBC           0 :         case xlnt::detail::hash_algorithm::sha1:
      68            [ # ]:              0 :             return "SHA1";
      69                 :              0 :         case xlnt::detail::hash_algorithm::sha256:
      70            [ # ]:              0 :             return "SHA256";
      71                 :              0 :         case xlnt::detail::hash_algorithm::sha384:
      72            [ # ]:              0 :             return "SHA384";
      73                 :CBC           4 :         case xlnt::detail::hash_algorithm::sha512:
      74            [ + ]:              8 :             return "SHA512";
      75                 :UBC           0 :         case xlnt::detail::hash_algorithm::md5:
      76            [ # ]:              0 :             return "MD5";
      77                 :              0 :         case xlnt::detail::hash_algorithm::md4:
      78            [ # ]:              0 :             return "MD4";
      79                 :              0 :         case xlnt::detail::hash_algorithm::md2:
      80            [ # ]:              0 :             return "MD2";
      81                 :              0 :         case xlnt::detail::hash_algorithm::ripemd128:
      82            [ # ]:              0 :             return "Ripemd128";
      83                 :              0 :         case xlnt::detail::hash_algorithm::ripemd160:
      84            [ # ]:              0 :             return "Ripemd160";
      85                 :              0 :         case xlnt::detail::hash_algorithm::whirlpool:
      86            [ # ]:              0 :             return "Whirlpool";
      87                 :                :         }
      88            [ # ]:              0 :         default_case("SHA1");
      89                 :                :     }
      90                 :                : }; // struct value_traits<xlnt::detail::hash_algorithm>
      91                 :                : 
      92                 :                : } // namespace xml
        

Generated by: LCOV version 2.3.1-beta