39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#include <filesystem>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <fesa/core/diagnostic.hpp>
|
|
|
|
namespace {
|
|
|
|
TEST(Diagnostic, PreservesSourceLocation) {
|
|
const fesa::Diagnostic diagnostic{
|
|
fesa::DiagnosticStage::syntax,
|
|
fesa::Severity::error,
|
|
"ABAQUS_INVALID_NODE",
|
|
"Node data is incomplete.",
|
|
fesa::SourceLocation{
|
|
std::filesystem::path{"models/beam.inp"}, 42, 9}};
|
|
|
|
ASSERT_TRUE(diagnostic.source.has_value());
|
|
EXPECT_EQ(
|
|
diagnostic.source->file, std::filesystem::path{"models/beam.inp"});
|
|
EXPECT_EQ(diagnostic.source->line, 42U);
|
|
EXPECT_EQ(diagnostic.source->column, 9U);
|
|
}
|
|
|
|
TEST(Diagnostic, AllowsDiagnosticsWithoutSourceLocation) {
|
|
const fesa::Diagnostic diagnostic{
|
|
fesa::DiagnosticStage::solver,
|
|
fesa::Severity::warning,
|
|
"SOLVER_RESIDUAL",
|
|
"Residual is above the reporting threshold.",
|
|
std::nullopt};
|
|
|
|
EXPECT_FALSE(diagnostic.source.has_value());
|
|
}
|
|
|
|
} // namespace
|