mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
#14517 Share the mock case factory between the summary tests
RimDeltaSummaryEnsemble-Test.cpp and RimSummaryCaseMainCollection-Test.cpp each defined an identical createMockCase() in an anonymous namespace. A unity build concatenates the two translation units, which merges the two anonymous namespaces into one and makes the second definition a redefinition, breaking the build with C2084. Move the factory to RimMockSummaryCase.h, the header both tests already include for the mock case itself, and drop both local copies.
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
#include "Summary/RiaSummaryTools.h"
|
||||
|
||||
#include "RigCaseRealizationParameters.h"
|
||||
|
||||
#include "RimDeltaSummaryEnsemble.h"
|
||||
#include "RimMockSummaryCase.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
@@ -15,22 +13,10 @@
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
RimSummaryCase* createMockCase( int realizationNumber )
|
||||
{
|
||||
auto* summaryCase = new RimMockSummaryCase();
|
||||
|
||||
auto parameters = std::make_shared<RigCaseRealizationParameters>();
|
||||
parameters->setRealizationNumber( realizationNumber );
|
||||
summaryCase->setCaseRealizationParameters( parameters );
|
||||
|
||||
return summaryCase;
|
||||
}
|
||||
|
||||
size_t countOf( const std::vector<RimDeltaSummaryEnsemble*>& ensembles, const RimDeltaSummaryEnsemble* ensemble )
|
||||
{
|
||||
return static_cast<size_t>( std::count( ensembles.begin(), ensembles.end(), ensemble ) );
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
#include "RigCaseRealizationParameters.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -63,3 +65,17 @@ private:
|
||||
QString m_name = "MockCase";
|
||||
std::map<RifEclipseSummaryAddress, VectorData> m_data;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// A mock case carrying the realization number a delta ensemble matches its source cases on.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
inline RimSummaryCase* createMockCase( int realizationNumber )
|
||||
{
|
||||
auto* summaryCase = new RimMockSummaryCase();
|
||||
|
||||
auto parameters = std::make_shared<RigCaseRealizationParameters>();
|
||||
parameters->setRealizationNumber( realizationNumber );
|
||||
summaryCase->setCaseRealizationParameters( parameters );
|
||||
|
||||
return summaryCase;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include "Summary/RiaSummaryTools.h"
|
||||
|
||||
#include "RigCaseRealizationParameters.h"
|
||||
|
||||
#include "RimDeltaSummaryEnsemble.h"
|
||||
#include "RimMockSummaryCase.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
@@ -13,23 +11,8 @@
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
RimSummaryCase* createMockCase( int realizationNumber )
|
||||
{
|
||||
auto* summaryCase = new RimMockSummaryCase();
|
||||
|
||||
auto parameters = std::make_shared<RigCaseRealizationParameters>();
|
||||
parameters->setRealizationNumber( realizationNumber );
|
||||
summaryCase->setCaseRealizationParameters( parameters );
|
||||
|
||||
return summaryCase;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Removing a source case makes a delta ensemble rebuild its derived cases. Those derived cases are
|
||||
/// part of the list of cases to remove, and must stay alive for as long as the caller holds that
|
||||
|
||||
Reference in New Issue
Block a user