LCOV - code coverage report
Current view: top level - core - dict.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 12 100.0 %
Date: 2024-11-17 01:47:58 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : /// @file
       4             : /// @author Jan-Lukas Wynen
       5             : 
       6             : #include "scipp/core/dict.h"
       7             : 
       8             : #include <sstream>
       9             : 
      10             : namespace scipp::core {
      11             : template <class It>
      12        4623 : std::string dict_keys_to_string(It it, const It end,
      13             :                                 const std::string_view &dict_name) {
      14        4623 :   std::ostringstream ss;
      15        4623 :   ss << "<" << dict_name << " {";
      16        4623 :   bool first = true;
      17       16871 :   for (; it != end; ++it) {
      18       12248 :     if (!first) {
      19        7647 :       ss << ", ";
      20             :     } else {
      21        4601 :       first = false;
      22             :     }
      23       12248 :     ss << *it;
      24             :   }
      25        4623 :   ss << "}>";
      26        9246 :   return ss.str();
      27        4623 : }
      28             : 
      29             : // The value type does not matter here, so set it to something simple.
      30             : using dim_dict_key_iterator = Dict<Dim, int>::const_key_iterator;
      31             : using str_dict_key_iterator = Dict<std::string, int>::const_key_iterator;
      32             : 
      33             : template SCIPP_CORE_EXPORT std::string
      34             : dict_keys_to_string(dim_dict_key_iterator, dim_dict_key_iterator,
      35             :                     const std::string_view &);
      36             : template SCIPP_CORE_EXPORT std::string
      37             : dict_keys_to_string(str_dict_key_iterator, str_dict_key_iterator,
      38             :                     const std::string_view &);
      39             : } // namespace scipp::core

Generated by: LCOV version 1.14