void TestOutputPlot::testTimeStep1D() { QString filePath = TestOutputPlot::filePath("timestep_1d.xml"); SimulationMaker maker; Simulation * sim = 0; try { sim = maker.parse(filePath); } catch (Exception &ex) { QString msg = "Unexpected exception. " + ex.message(); QFAIL(qPrintable(msg)); } OutputPlot *plot = sim->seekOneChild<OutputPlot*>("*"); QVERIFY(plot); QList<OutputPlot::TableRecord> records = plot->tableRecords(); QCOMPARE(records.size(), 1); OutputPlot::TableRecord &rec(records[0]); QCOMPARE(rec.x.size(), 32); QCOMPARE(rec.x[0], 1.); QCOMPARE(rec.x[1], 3.); QCOMPARE(rec.x[31], (double) QDate(2008,4,1).daysTo(QDate(2008,8,15))); QCOMPARE(rec.yList.size(), 4); QStringList labels, expectedLabels; expectedLabels << "DIGSA" << "ELEIN" << "SETGL" << "SETVI"; for (int i = 0; i < rec.yList.size(); ++i) { labels << rec.yList[i].label; } QCOMPARE(labels, expectedLabels); checkY(rec.yList[0].data, 0, 0.3, 96.6); checkY(rec.yList[3].data, 13, 22.3, 99.3); }
void TestSimulationMakerFromFile::createSimulation(QString fileName) { SimulationMaker maker; try { sim = maker.parse(filePath(fileName)); } catch (Exception &ex) { QString msg = "Unexpected exception. " + ex.message(); QFAIL(qPrintable(msg)); } }
void TestSimulationMaker::initTestCase() { writeStandardTestFile(local::testFilePath()); simulation = 0; SimulationMaker maker; try { simulation = maker.parse(local::testFilePath()); } catch (const Exception &ex) { delete simulation; simulation = 0; QFAIL(qPrintable(ex.message())); } QVERIFY(simulation==UniSim::simulation()); }
void runSimulation(QString fileName) { QString absFilePath = xmlModelsTestFolder().absolutePath() + "/" + fileName; SimulationMaker maker; try { struct finally { ~finally() { delete sim; sim = 0; } void touch() {} } finale; finale.touch(); sim = maker.parse(absFilePath); sim->execute(); } catch (Exception &ex) { throw ex; } }
void TestSimulationMaker::initTestCase() { writeStandardTestFile(local::testFilePath()); _simulation = 0; SimulationMaker maker; bool modelOk = false; try { _simulation = maker.parse(local::testFilePath()); UniSim::setSimulationObject(_simulation); modelOk = true; } catch (const Exception &ex) { delete _simulation; _simulation = 0; QWARN(qPrintable(ex.message())); QVERIFY(false); } }
void TestRecords::createSimulation(QString fileName) { QDir dir = FileLocations::location(FileLocationInfo::Plugins); QString filePath = dir.absolutePath() + "/unisim_models/test/" + fileName; SimulationMaker maker; sim = maker.parse(filePath); }