error_builders_test.cpp 700 B

1234567891011121314151617181920212223242526
  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 "explorer/base/error_builders.h"
  5. #include <gtest/gtest.h>
  6. #include "explorer/base/source_location.h"
  7. #include "testing/base/test_raw_ostream.h"
  8. namespace Carbon {
  9. namespace {
  10. TEST(ErrorBuildersTest, ProgramError) {
  11. Error err = ProgramError(SourceLocation("x", 1, FileKind::Main)) << "test";
  12. EXPECT_EQ(err.location(), "x:1");
  13. EXPECT_EQ(err.message(), "test");
  14. Testing::TestRawOstream out;
  15. out << err;
  16. EXPECT_EQ(out.TakeStr(), "x:1: test");
  17. }
  18. } // namespace
  19. } // namespace Carbon