Files
carbon-lang/executable_semantics/common/error_test.cpp
T
Jon Meow 2e9e4f4cb3 Migrate remaining exits to FATAL_*_ERROR calls (#704)
Adds FATAL for things that are most likely programming errors in executable_semantics.
2021-08-06 13:06:25 -07:00

34 lines
922 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "executable_semantics/common/error.h"
#include "gtest/gtest.h"
namespace Carbon {
namespace {
TEST(ErrorTest, FatalProgramError) {
ASSERT_DEATH({ FATAL_PROGRAM_ERROR_NO_LINE() << "test"; },
"^PROGRAM ERROR: test\n");
}
TEST(ErrorTest, FatalRuntimeError) {
ASSERT_DEATH({ FATAL_RUNTIME_ERROR_NO_LINE() << "test"; },
"^RUNTIME ERROR: test\n");
}
TEST(ErrorTest, FatalCompilationError) {
ASSERT_DEATH({ FATAL_COMPILATION_ERROR_NO_LINE() << "test"; },
"^COMPILATION ERROR: test\n");
}
TEST(ErrorTest, FatalProgramErrorLine) {
ASSERT_DEATH({ FATAL_PROGRAM_ERROR(1) << "test"; },
"^PROGRAM ERROR: 1: test\n");
}
} // namespace
} // namespace Carbon