File indexing completed on 2024-05-19 04:34:08
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 ***************************************************************************/ 0011 0012 #include "testgeneratedmatrix.h" 0013 0014 #include <QtTest> 0015 0016 #include <generatedmatrix.h> 0017 #include <datasource.h> 0018 #include <math_kst.h> 0019 #include <datacollection.h> 0020 #include <objectstore.h> 0021 0022 #include <QXmlStreamAttributes> 0023 0024 static Kst::ObjectStore _store; 0025 0026 void TestGeneratedMatrix::cleanupTestCase() { 0027 _store.clear(); 0028 } 0029 0030 0031 void TestGeneratedMatrix::testGeneratedMatrix() { 0032 bool ok = true; 0033 0034 //basic default constructor values 0035 Kst::GeneratedMatrixPtr m1 = Kst::kst_cast<Kst::GeneratedMatrix>(_store.createObject<Kst::GeneratedMatrix>()); 0036 QCOMPARE(m1->sampleCount(), 1); 0037 QCOMPARE(m1->minValue(), 0.0); 0038 QCOMPARE(m1->maxValue(), 0.0); 0039 QCOMPARE(m1->value(0, 0, &ok), 0.0); 0040 QVERIFY(ok); 0041 QCOMPARE(m1->value(10, 10, &ok), 0.0); //should be outside the boundaries. 0042 QVERIFY(!ok); 0043 QCOMPARE(m1->meanValue(), 0.0); 0044 0045 m1->change(10, 10, 0, 0, 1, 1, 0, 100, 0); 0046 0047 m1->writeLock(); 0048 m1->internalUpdate(); 0049 m1->unlock(); 0050 0051 QCOMPARE(m1->sampleCount(), 100); 0052 QCOMPARE(m1->minValue(), 0.0); 0053 QCOMPARE(m1->maxValue(), 100.0); 0054 QCOMPARE(m1->value(0, 0, &ok), 0.0); 0055 QVERIFY(ok); 0056 QCOMPARE(m1->value(0, 9, &ok), 100.0); 0057 QVERIFY(ok); 0058 } 0059 0060 #ifdef KST_USE_QTEST_MAIN 0061 QTEST_MAIN(TestGeneratedMatrix) 0062 #endif 0063 0064 // vim: ts=2 sw=2 et