1
/*************************************************************************************
2
* Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org> *
4
* This program is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU General Public License *
6
* as published by the Free Software Foundation; either version 2 *
7
* of the License, or (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the Free Software *
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
17
*************************************************************************************/
19
#include "operatorsmodeltest.h"
20
#include <analitza/expression.h>
21
#include <analitza/analyzer.h>
22
#include <analitza/variables.h>
23
#include <qtest_kde.h>
25
#include <analitza/analitzautils.h>
26
#include <analitza/value.h>
29
using Analitza::Expression;
31
QTEST_KDEMAIN_CORE( OperatorsModelTest )
33
OperatorsModelTest::OperatorsModelTest(QObject *parent)
37
OperatorsModelTest::~OperatorsModelTest() {}
38
void OperatorsModelTest::initTestCase() {}
39
void OperatorsModelTest::cleanupTestCase() {}
41
void OperatorsModelTest::testExamples_data()
43
QTest::addColumn<int>("i");
44
for(int i=0; i<m.rowCount(); i++) {
45
QModelIndex idx(m.index(i, 0));
46
QTest::newRow(qPrintable(idx.data().toString())) << i;
50
void OperatorsModelTest::testExamples()
53
QModelIndex idx(m.index(i, 0));
55
QModelIndex nameIdx, descriptionIdx, sampleIdx, exampleIdx;
56
nameIdx = idx.sibling(idx.row(), 0);
57
descriptionIdx = idx.sibling(idx.row(), 1);
58
sampleIdx = idx.sibling(idx.row(), 2);
59
exampleIdx = idx.sibling(idx.row(), 3);
61
QString name=m.data(nameIdx).toString();
62
QString description=m.data(descriptionIdx).toString();
63
QString sample=m.data(sampleIdx).toString();
64
QString example=m.data(exampleIdx).toString();
66
// qDebug() << "testing: " << name << example;
68
QVERIFY(!name.isEmpty());
69
QVERIFY(!description.isEmpty());
70
QVERIFY(!sample.isEmpty());
71
QVERIFY(!example.isEmpty());
72
Expression ex(example, false);
73
QCOMPARE(ex.toString(), example);
74
QVERIFY(!ex.toMathMLPresentation().isEmpty());
79
if(!a.isCorrect()) qDebug() << example << "1. error" << a.errors();// QVERIFY(a.isCorrect());
82
if(!a.isCorrect()) qDebug() << example << "2. error" << a.errors();// QVERIFY(a.isCorrect());
83
a.variables()->modify("x", 0.1);
85
Expression e = a.calculate();
86
if(!a.isCorrect()) qDebug() << example << "3. error" << a.errors();// QVERIFY(a.isCorrect());
87
if(!e.isCorrect()) qDebug() << example << "4. error" << e.error(); // QVERIFY(e.isCorrect());
90
if(!a.isCorrect()) qDebug() << example << "5. error" << a.errors();// QVERIFY(a.isCorrect());
91
if(!e.isCorrect()) qDebug() << example << "6. error" << e.error(); // QVERIFY(e.isCorrect());
92
QVERIFY(!a.expression().toMathMLPresentation().isEmpty());
95
#include "operatorsmodeltest.moc"