mocks.cpp 1020 B

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