mocks.cpp 971 B

1234567891011121314151617181920212223242526272829303132
  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.message.kind << ", ";
  8. PrintTo(diagnostic.level, os);
  9. *os << ", " << diagnostic.message.location.file_name << ":"
  10. << diagnostic.message.location.line_number << ":"
  11. << diagnostic.message.location.column_number << ", \""
  12. << diagnostic.message.format_fn(diagnostic.message) << "\"}";
  13. }
  14. void PrintTo(DiagnosticLevel level, std::ostream* os) {
  15. switch (level) {
  16. case DiagnosticLevel::Note:
  17. *os << "Note";
  18. break;
  19. case DiagnosticLevel::Warning:
  20. *os << "Warning";
  21. break;
  22. case DiagnosticLevel::Error:
  23. *os << "Error";
  24. break;
  25. }
  26. }
  27. } // namespace Carbon