LCOV - code coverage report
Current view: top level - units - string.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 11 45.5 %
Date: 2024-11-24 01:48:31 Functions: 3 4 75.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 Simon Heybrock
       5             : #include "scipp/units/string.h"
       6             : #include <sstream>
       7             : 
       8             : namespace scipp::units {
       9             : 
      10       12441 : std::ostream &operator<<(std::ostream &os, const Dim dim) {
      11       12441 :   return os << to_string(dim);
      12             : }
      13             : 
      14         176 : std::ostream &operator<<(std::ostream &os, const Unit unit) {
      15         176 :   return os << to_string(unit);
      16             : }
      17             : 
      18         783 : std::string to_string(const units::Unit &unit) { return unit.name(); }
      19             : 
      20           0 : template <class T> std::string to_string(const std::initializer_list<T> items) {
      21           0 :   std::stringstream ss;
      22             : 
      23           0 :   for (const auto &item : items) {
      24           0 :     ss << to_string(item) << " ";
      25             :   }
      26             : 
      27           0 :   return ss.str();
      28           0 : }
      29             : 
      30             : template SCIPP_UNITS_EXPORT std::string to_string<scipp::units::Unit>(
      31             :     const std::initializer_list<scipp::units::Unit> items);
      32             : 
      33             : } // namespace scipp::units

Generated by: LCOV version 1.14