-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.54..v0.2.55 changeset TestUtils.cpp
Garret Voltz edited this page Aug 14, 2020
·
1 revision
diff --git a/hoot-core-test/src/test/cpp/hoot/core/TestUtils.cpp b/hoot-core-test/src/test/cpp/hoot/core/TestUtils.cpp
index 68b75ca..01bfc2c 100644
--- a/hoot-core-test/src/test/cpp/hoot/core/TestUtils.cpp
+++ b/hoot-core-test/src/test/cpp/hoot/core/TestUtils.cpp
@@ -41,7 +41,7 @@
#include <hoot/core/util/UuidHelper.h>
#include <hoot/core/visitors/FilteredVisitor.h>
#include <hoot/core/visitors/UniqueElementIdVisitor.h>
-#include <hoot/core/cmd/ConflateCmd.h>
+#include <hoot/core/conflate/SuperfluousConflateOpRemover.h>
#include <hoot/core/util/ConfPath.h>
// tgs
@@ -202,14 +202,11 @@ ElementPtr TestUtils::getElementWithTag(OsmMapPtr map, const QString& tagKey,
return map->getElement(*bag.begin());
}
-std::shared_ptr<TestUtils> TestUtils::getInstance()
+TestUtils& TestUtils::getInstance()
{
- if (!_theInstance)
- {
- _theInstance.reset(new TestUtils());
- }
-
- return _theInstance;
+ // Local static singleton instance
+ static TestUtils instance;
+ return instance;
}
std::string TestUtils::readFile(QString f1)
@@ -255,7 +252,7 @@ void TestUtils::resetEnvironment(const QStringList confs)
LOG_VART(confs[i]);
conf().loadJson(confs[i]);
}
- LOG_VART(conf());
+ //LOG_VART(conf());
conf().set("HOOT_HOME", getenv("HOOT_HOME"));
// Sometimes we add new projections to the MapProjector, when this happens it may pick a new
@@ -270,7 +267,7 @@ void TestUtils::resetEnvironment(const QStringList confs)
// make sure the UUIDs are repeatable
UuidHelper::resetRepeatableKey();
- foreach (RegisteredReset* rr, getInstance()->_resets)
+ foreach (RegisteredReset* rr, getInstance()._resets)
{
rr->reset();
}
@@ -311,26 +308,6 @@ void TestUtils::verifyStdMatchesOutputIgnoreDate(const QString& stdFilePath,
}
}
-bool TestUtils::mkpath(const QString& path)
-{
- // Don't make it if it exists
- if (QDir().exists(path))
- return true;
- // Try to make the path 'retry' times waiting 'duration' microseconds in between tries
- const int retry = 3;
- // 100 msec should be enough to wait between tries
- const unsigned int duration = 100000;
- for (int i = 0; i < retry; i++)
- {
- if (QDir().mkpath(path))
- return true;
- usleep(duration);
- }
- // Report failure
- CPPUNIT_FAIL(QString("Couldn't create output directory: %1").arg(path).toStdString());
- return false;
-}
-
QStringList TestUtils::getConflateCmdSnapshotPreOps()
{
QStringList conflatePreOps;
@@ -391,9 +368,6 @@ void TestUtils::runConflateOpReductionTest(
{
QStringList actualOps;
- ConflateCmd uut;
- uut.setFilterOps(true);
-
CPPUNIT_ASSERT_EQUAL(4, TestUtils::getConflateCmdSnapshotPreOps().size());
CPPUNIT_ASSERT_EQUAL(15, TestUtils::getConflateCmdSnapshotPostOps().size());
CPPUNIT_ASSERT_EQUAL(17, TestUtils::getConflateCmdSnapshotCleaningOps().size());
@@ -408,7 +382,7 @@ void TestUtils::runConflateOpReductionTest(
conf().set(
ConfigOptions::getMapCleanerTransformsKey(), TestUtils::getConflateCmdSnapshotCleaningOps());
- uut._removeSuperfluousOps();
+ SuperfluousConflateOpRemover::removeSuperfluousOps();
actualOps = conf().getList(ConfigOptions::getConflatePreOpsKey());
CPPUNIT_ASSERT_EQUAL(expectedPreOpSize, actualOps.size());