error_test.cpp 940 B

123456789101112131415161718192021222324252627282930313233
  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.h"
  5. #include <gtest/gtest.h>
  6. namespace Carbon::Testing {
  7. namespace {
  8. TEST(ErrorTest, FatalProgramError) {
  9. ASSERT_DEATH({ FATAL_PROGRAM_ERROR_NO_LINE() << "test"; },
  10. "^PROGRAM ERROR: test\n");
  11. }
  12. TEST(ErrorTest, FatalRuntimeError) {
  13. ASSERT_DEATH({ FATAL_RUNTIME_ERROR_NO_LINE() << "test"; },
  14. "^RUNTIME ERROR: test\n");
  15. }
  16. TEST(ErrorTest, FatalCompilationError) {
  17. ASSERT_DEATH({ FATAL_COMPILATION_ERROR_NO_LINE() << "test"; },
  18. "^COMPILATION ERROR: test\n");
  19. }
  20. TEST(ErrorTest, FatalProgramErrorLine) {
  21. ASSERT_DEATH({ FATAL_PROGRAM_ERROR(1) << "test"; },
  22. "^PROGRAM ERROR: 1: test\n");
  23. }
  24. } // namespace
  25. } // namespace Carbon::Testing