#include #include #include #include #include #include #include "eigen_reference_comparison.h" #include "fesa/app/fesa_application.h" #ifndef FESA_TEST_SOURCE_DIR #error FESA_TEST_SOURCE_DIR must identify the repository root. #endif #ifndef FESA_TEST_BINARY_DIR #error FESA_TEST_BINARY_DIR must identify the CMake binary root. #endif namespace { std::string ReadBytes(const std::filesystem::path& path) { std::ifstream stream{path, std::ios::binary}; if (!stream) { throw std::runtime_error{"Unable to read declared eigen artifact."}; } return {std::istreambuf_iterator{stream}, std::istreambuf_iterator{}}; } // E2-C25. TEST(EigenReference, RunsOriginalInputAndComparesAllModalFrameIdentities) { const std::filesystem::path source_root{FESA_TEST_SOURCE_DIR}; const std::filesystem::path reference_directory = source_root / "reference" / "shellNL-eigen-meshfine"; const std::filesystem::path input = reference_directory / "shellNL-eigen-meshfine.inp"; const std::filesystem::path text = reference_directory / "shellNL-eigen-meshfine eigenvalues.txt"; const std::string input_before = ReadBytes(input); const std::string text_before = ReadBytes(text); fesa::FesaApplication application; const int exit_code = application.Run({input.string()}); EXPECT_EQ(ReadBytes(input), input_before); EXPECT_EQ(ReadBytes(text), text_before); ASSERT_EQ(exit_code, 0); const std::filesystem::path results = reference_directory / "shellNL-eigen-meshfine_results.h5"; ASSERT_TRUE(std::filesystem::is_regular_file(results)); const auto comparison = fesa::test::EigenReferenceComparison::Compare( {"shellnl-eigen-meshfine", input, text, results}); ASSERT_TRUE(comparison.HasValue()); EXPECT_TRUE(comparison.Value().passed); EXPECT_EQ(comparison.Value().source_step_name, "Step-2"); EXPECT_EQ(comparison.Value().requested_mode_count, 10U); ASSERT_EQ(comparison.Value().rows.size(), 10U); ASSERT_EQ(comparison.Value().families.size(), 10U); for (std::size_t index = 0U; index < comparison.Value().rows.size(); ++index) { EXPECT_EQ(comparison.Value().rows[index].mode_id, index + 1U); EXPECT_EQ(comparison.Value().rows[index].component, "Value"); EXPECT_EQ(comparison.Value().families[index].row_count, 1U); EXPECT_TRUE(comparison.Value().families[index].passed); } EXPECT_EQ(ReadBytes(input), input_before); EXPECT_EQ(ReadBytes(text), text_before); } } // namespace