Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 Werner 1
#include <QtTest/QtTest>
2
#include <QtXml>
3
#include <QtSql>
4
 
5
#include "global.h"
6
#include "model.h"
7
#include "ressourceunit.h"
8
#include "xmlhelper.h"
9
#include "speciesset.h"
10
#include "species.h"
11
class TestModelCreate: public QObject
12
{
13
    Q_OBJECT
14
private:
15
    Model *model;
16
private slots:
17
    void initTestCase();
18
    void cleanupTestCase();
19
 
20
    void speciesFormula();
21
    void speciesFormulaStraight();
22
};
23
 
24
 
25
void TestModelCreate::initTestCase()
26
{
102 Werner 27
    //XmlHelper xml("E:\\dev\\iland\\src\\tests\\modelCreate\\test.xml");
28
    try {
29
        model = new Model();
30
        GlobalSettings::instance()->loadProjectFile("E:\\dev\\iland\\src\\tests\\modelCreate\\test.xml");
31
        model->loadProject();
32
    } catch (const IException &e) {
33
        qDebug() << "Exception:" << e.asString();
34
    }
95 Werner 35
}
36
 
37
void TestModelCreate::cleanupTestCase()
38
{
39
    delete model;
40
}
41
 
42
void TestModelCreate::speciesFormula()
43
{
44
    Species *species = model->ru()->speciesSet()->species("piab");
45
    QVERIFY(species!=0);
46
    // equation: m = 1.2*d^1.5
47
    QCOMPARE(qRound(species->biomassLeaf(2)),3);
48
    QCOMPARE(qRound(species->biomassLeaf(20)),107);
49
    QCOMPARE(qRound(species->biomassLeaf(50)),424);
50
    QCOMPARE(qRound(species->biomassLeaf(100)),1200);
51
 
52
    double x, y;
53
    y=56.;
54
    QBENCHMARK {
55
             x = species->biomassLeaf(y);
56
    }
57
 
58
}
59
void TestModelCreate::speciesFormulaStraight()
60
{
61
    double x,y=56.;
62
    QBENCHMARK {
63
             x = 1.2 * pow(y, 1.5);
64
    }
65
}
66
 
67
 
68
QTEST_MAIN(TestModelCreate)
69
#include "testModelCreate.moc"
70
 
71