LCOV - code coverage report
Current view: top level - variable - except.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 9 77.8 %
Date: 2024-12-01 01:56:34 Functions: 3 3 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             : #include "scipp/variable/except.h"
       6             : #include "scipp/variable/variable_factory.h"
       7             : 
       8             : namespace scipp::except {
       9          50 : VariableError::VariableError(const std::string &msg) : Error{msg} {}
      10             : 
      11             : template <>
      12           5 : void throw_mismatch_error(const variable::Variable &expected,
      13             :                           const variable::Variable &actual,
      14             :                           const std::string &optional_message) {
      15          15 :   throw VariableError("Expected\n" + to_string(expected) + ", got\n" +
      16          20 :                       to_string(actual) + '.' + optional_message);
      17             : }
      18             : } // namespace scipp::except
      19             : 
      20             : namespace scipp::variable {
      21             : 
      22          29 : std::string pretty_dtype(const Variable &var) {
      23          29 :   if (!is_bins(var))
      24          29 :     return to_string(var.dtype());
      25           0 :   return to_string(var.dtype()) +
      26           0 :          "(dtype=" + pretty_dtype(variableFactory().elem_dtype(var)) + ")";
      27             : }
      28             : 
      29             : } // namespace scipp::variable

Generated by: LCOV version 1.14