feat(cpp-object-oriented-modular-refactoring): step 3 - foundation-google-style
This commit is contained in:
@@ -78,12 +78,12 @@ struct DofFixture {
|
||||
|
||||
DofFixture makeDofFixture(fesa::ModelDefinition definition = makeDefinition()) {
|
||||
auto domain = fesa::Domain::create(std::move(definition));
|
||||
EXPECT_TRUE(domain.hasValue());
|
||||
auto model = fesa::AnalysisModel::create(domain.value());
|
||||
EXPECT_TRUE(model.hasValue());
|
||||
auto dofs = fesa::DofManager::create(model.value());
|
||||
EXPECT_TRUE(dofs.hasValue());
|
||||
return {std::move(dofs.value())};
|
||||
EXPECT_TRUE(domain.HasValue());
|
||||
auto model = fesa::AnalysisModel::create(domain.Value());
|
||||
EXPECT_TRUE(model.HasValue());
|
||||
auto dofs = fesa::DofManager::create(model.Value());
|
||||
EXPECT_TRUE(dofs.HasValue());
|
||||
return {std::move(dofs.Value())};
|
||||
}
|
||||
|
||||
std::vector<std::size_t> rowColumns(
|
||||
@@ -122,7 +122,7 @@ TEST(DofManager, NumbersSixDofsAndFreeEquationsStably) {
|
||||
TEST(DofManager, ExpandsAndValidatesPrescribedValues) {
|
||||
const auto fixture = makeDofFixture();
|
||||
const auto& values = fixture.dofs.prescribedValues();
|
||||
ASSERT_EQ(values.size(), 5U);
|
||||
ASSERT_EQ(values.Size(), 5U);
|
||||
EXPECT_DOUBLE_EQ(values[0], 0.0);
|
||||
EXPECT_DOUBLE_EQ(values[1], 0.0);
|
||||
EXPECT_DOUBLE_EQ(values[2], 0.25);
|
||||
@@ -133,18 +133,18 @@ TEST(DofManager, ExpandsAndValidatesPrescribedValues) {
|
||||
conflictingDefinition.steps[0].boundaries.push_back(
|
||||
{"root", 1, 1, 1.0, {conflictingDefinition.sourcePath, 77U}});
|
||||
auto domain = fesa::Domain::create(std::move(conflictingDefinition));
|
||||
ASSERT_TRUE(domain.hasValue());
|
||||
auto model = fesa::AnalysisModel::create(domain.value());
|
||||
ASSERT_TRUE(model.hasValue());
|
||||
ASSERT_TRUE(domain.HasValue());
|
||||
auto model = fesa::AnalysisModel::create(domain.Value());
|
||||
ASSERT_TRUE(model.HasValue());
|
||||
|
||||
auto conflict = fesa::DofManager::create(model.value());
|
||||
ASSERT_FALSE(conflict.hasValue());
|
||||
EXPECT_EQ(conflict.status().failureCategory(), fesa::FailureCategory::input);
|
||||
ASSERT_EQ(conflict.status().diagnostics().size(), 1U);
|
||||
const auto& diagnostic = conflict.status().diagnostics()[0];
|
||||
auto conflict = fesa::DofManager::create(model.Value());
|
||||
ASSERT_FALSE(conflict.HasValue());
|
||||
EXPECT_EQ(conflict.GetStatus().Category(), fesa::FailureCategory::kInput);
|
||||
ASSERT_EQ(conflict.GetStatus().Diagnostics().size(), 1U);
|
||||
const auto& diagnostic = conflict.GetStatus().Diagnostics()[0];
|
||||
EXPECT_EQ(diagnostic.code, "conflicting-boundary-condition");
|
||||
EXPECT_EQ(diagnostic.keyword, "BOUNDARY");
|
||||
EXPECT_EQ(diagnostic.entityIdentity, "root");
|
||||
EXPECT_EQ(diagnostic.entity_identity, "root");
|
||||
EXPECT_EQ(diagnostic.location.file, std::filesystem::path{"models/dof-manager.inp"});
|
||||
EXPECT_EQ(diagnostic.location.line, 77U);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ TEST(DofManager, ReconstructsFullReducedRoundTrip) {
|
||||
const auto fixture = makeDofFixture();
|
||||
const auto& dofs = fixture.dofs;
|
||||
fesa::Vector full{dofs.fullDofCount()};
|
||||
for (std::size_t index = 0U; index < full.size(); ++index) {
|
||||
for (std::size_t index = 0U; index < full.Size(); ++index) {
|
||||
full[index] = static_cast<double>(index) + 0.5;
|
||||
}
|
||||
for (std::size_t index = 0U; index < dofs.constrainedDofCount(); ++index) {
|
||||
@@ -235,19 +235,19 @@ TEST(DofManager, ReconstructsFullReducedRoundTrip) {
|
||||
}
|
||||
|
||||
fesa::Vector reduced{dofs.freeDofCount()};
|
||||
for (std::size_t equation = 0U; equation < reduced.size(); ++equation) {
|
||||
for (std::size_t equation = 0U; equation < reduced.Size(); ++equation) {
|
||||
reduced[equation] = full[dofs.freeDofs()[equation]];
|
||||
}
|
||||
fesa::Vector reconstructed{dofs.fullDofCount()};
|
||||
for (std::size_t equation = 0U; equation < reduced.size(); ++equation) {
|
||||
for (std::size_t equation = 0U; equation < reduced.Size(); ++equation) {
|
||||
reconstructed[dofs.freeDofs()[equation]] = reduced[equation];
|
||||
}
|
||||
for (std::size_t index = 0U; index < dofs.constrainedDofCount(); ++index) {
|
||||
reconstructed[dofs.constrainedDofs()[index]] = dofs.prescribedValues()[index];
|
||||
}
|
||||
|
||||
ASSERT_EQ(reconstructed.size(), full.size());
|
||||
for (std::size_t index = 0U; index < full.size(); ++index) {
|
||||
ASSERT_EQ(reconstructed.Size(), full.Size());
|
||||
for (std::size_t index = 0U; index < full.Size(); ++index) {
|
||||
EXPECT_DOUBLE_EQ(reconstructed[index], full[index]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user