error_builders_test.cpp 918 B

123456789101112131415161718192021222324252627282930
  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 "executable_semantics/common/error_builders.h"
  5. #include <gtest/gtest.h>
  6. #include "executable_semantics/common/source_location.h"
  7. namespace Carbon::Testing {
  8. namespace {
  9. TEST(ErrorBuildersTest, CompilationError) {
  10. Error err = CompilationError(SourceLocation("x", 1)) << "test";
  11. EXPECT_EQ(err.message(), "COMPILATION ERROR: x:1: test");
  12. }
  13. TEST(ErrorBuildersTest, ProgramError) {
  14. Error err = ProgramError(SourceLocation("x", 1)) << "test";
  15. EXPECT_EQ(err.message(), "PROGRAM ERROR: x:1: test");
  16. }
  17. TEST(ErrorBuildersTest, RuntimeError) {
  18. Error err = RuntimeError(SourceLocation("x", 1)) << "test";
  19. EXPECT_EQ(err.message(), "RUNTIME ERROR: x:1: test");
  20. }
  21. } // namespace
  22. } // namespace Carbon::Testing