mocks.cpp 760 B

12345678910111213141516171819202122
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/diagnostics/mocks.h"
  5. namespace Carbon {
  6. void PrintTo(const Diagnostic& diagnostic, std::ostream* os) {
  7. *os << "Diagnostic{" << diagnostic.kind << ", ";
  8. PrintTo(diagnostic.level, os);
  9. *os << ", " << diagnostic.location.file_name << ":"
  10. << diagnostic.location.line_number << ":"
  11. << diagnostic.location.column_number << ", \""
  12. << diagnostic.format_fn(diagnostic) << "\"}";
  13. }
  14. void PrintTo(DiagnosticLevel level, std::ostream* os) {
  15. *os << (level == DiagnosticLevel::Error ? "Error" : "Warning");
  16. }
  17. } // namespace Carbon