mocks.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. auto PrintTo(const Diagnostic& diagnostic, std::ostream* os) -> void {
  7. *os << "Diagnostic{";
  8. PrintTo(diagnostic.level, os);
  9. for (const auto& message : diagnostic.messages) {
  10. *os << ", {" << message.loc.filename << ":" << message.loc.line_number
  11. << ":" << message.loc.column_number << ", \"" << message.Format()
  12. << "}";
  13. }
  14. *os << "\"}";
  15. }
  16. auto PrintTo(DiagnosticLevel level, std::ostream* os) -> void {
  17. switch (level) {
  18. case DiagnosticLevel::LocationInfo:
  19. *os << "LocationInfo";
  20. break;
  21. case DiagnosticLevel::Note:
  22. *os << "Note";
  23. break;
  24. case DiagnosticLevel::Warning:
  25. *os << "Warning";
  26. break;
  27. case DiagnosticLevel::Error:
  28. *os << "Error";
  29. break;
  30. }
  31. }
  32. } // namespace Carbon