Commit 67bee711 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Fix broken tests. Add performance test.

parent 8cd54aae
......@@ -76,9 +76,9 @@ void HistoryView::unroll(std::vector<HistoryItem>::iterator &it) {
#else
// workaround for GCC < 4.9
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55817
for (const auto &item : tmpHistory) {
++it; // move iterator forward to insertion position
it = m_historyItems.insert(it, item);
++it;
for(auto itItem = tmpHistory.rbegin();itItem!=tmpHistory.rend();++itItem){
it = m_historyItems.insert(it, *itItem);
}
#endif
} else
......
......@@ -351,4 +351,87 @@ public:
size_t m_execCount;
};
class HistoryViewTestPerformance : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static HistoryViewTestPerformance *createSuite() { return new HistoryViewTestPerformance(); }
static void destroySuite(HistoryViewTestPerformance *suite) { delete suite; }
private:
// 'Empty' algorithm class for tests
class testalg : public Algorithm {
public:
testalg() : Algorithm() {}
virtual ~testalg() {}
const std::string summary() const {
return "testalg";
} ///< Algorithm's documentation summary
const std::string name() const {
return "testalg";
} ///< Algorithm's name for identification
int version() const {
return 1;
} ///< Algorithm's version for identification
const std::string category() const {
return "Cat";
} ///< Algorithm's category for identification
void init() { declareProperty("name", "", Direction::Input); }
void exec() {}
};
private:
AlgorithmHistory_sptr
createFromTestAlg(const std::string &name,
DateAndTime execTime = DateAndTime::defaultTime()) {
testalg alg;
alg.initialize();
alg.setPropertyValue("name", name);
alg.execute();
AlgorithmHistory history(&alg, execTime, 14.0, m_execCount++);
return boost::make_shared<AlgorithmHistory>(history);
}
public:
HistoryViewTestPerformance() : m_wsHist(), m_execCount(0) {
// create dummy history structure
for(std::size_t i = 0; i < 20; ++i)
{
auto alg = createFromTestAlg("alg"+boost::lexical_cast<std::string>(i), DateAndTime(100+i, 0));
for(std::size_t j = 0; j < 20; ++j)
{
auto childAlg = createFromTestAlg("child"+boost::lexical_cast<std::string>(j), DateAndTime(200+j, 0));
for (std::size_t k = 0; k < 20; ++k)
{
auto subChildAlg = createFromTestAlg("subChild"+boost::lexical_cast<std::string>(j)+boost::lexical_cast<std::string>(k), DateAndTime(300+k, 0));
childAlg->addChildHistory(subChildAlg);
}
alg->addChildHistory(childAlg);
}
m_wsHist.addHistory(alg);
}
}
void test_UnrollAll() {
HistoryView view(m_wsHist);
TS_ASSERT_THROWS_NOTHING(view.unrollAll());
}
void test_UnrollAllRollAll() {
HistoryView view(m_wsHist);
TS_ASSERT_THROWS_NOTHING(view.unrollAll());
TS_ASSERT_THROWS_NOTHING(view.rollAll());
}
WorkspaceHistory m_wsHist;
size_t m_execCount;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment