Allow to mark interpolator for unit tests (which can be used to disable some checks)

This commit is contained in:
Klaus Basan
2018-05-11 03:06:05 +02:00
parent a750c02520
commit 0f9b275f52
4 changed files with 11 additions and 2 deletions

View File

@@ -147,9 +147,12 @@ namespace BlackMisc
CInterpolationResult result;
do
{
if (!this->initIniterpolationStepData(currentTimeSinceEpoc, setup)) { break; }
if (!this->initIniterpolationStepData(currentTimeSinceEpoc, setup))
{
// make sure we can also interpolate parts only (needed in unit tests)
if (!m_unitTest) { break; }
}
// make sure we can also interpolate parts only (needed in unit tests for instance)
const CAircraftSituation interpolatedSituation = this->getInterpolatedSituation();
const CAircraftParts interpolatedParts = this->getInterpolatedOrGuessedParts();

View File

@@ -204,6 +204,9 @@ namespace BlackMisc
//! \remark either by passing a model or using the provider
void initCorrespondingModel(const CAircraftModel &model = {});
//! Mark as unit test
void markAsUnitTest() { m_unitTest = true; }
protected:
//! Constructor
CInterpolator(const Aviation::CCallsign &callsign,
@@ -249,6 +252,7 @@ namespace BlackMisc
qint64 m_situationsLastModifiedUsed { -1 }; //!< interpolant based on situations last updated
int m_interpolatedSituationsCounter { 0 }; //!< counter for each interpolated situations: statistics, every n-th interpolation ....
bool m_unitTest = false; //!< mark as unit test
//! Verify gnd flag, times, ... true means "OK"
bool verifyInterpolationSituations(const Aviation::CAircraftSituation &oldest, const Aviation::CAircraftSituation &newer, const Aviation::CAircraftSituation &latest,

View File

@@ -57,6 +57,7 @@ namespace BlackMiscTest
CCallsign cs("SWIFT");
CRemoteAircraftProviderDummy provider;
CInterpolatorLinear interpolator(cs, nullptr, nullptr, &provider);
// interpolator.markAsUnitTest();
// fixed time so everything can be debugged
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch();

View File

@@ -33,6 +33,7 @@ namespace BlackMiscTest
CCallsign cs("SWIFT");
CRemoteAircraftProviderDummy provider;
CInterpolatorSpline interpolator(cs, nullptr, nullptr, &provider);
interpolator.markAsUnitTest();
// fixed time so everything can be debugged
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch()