File indexing completed on 2024-05-19 04:34:08

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2010 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 "testgeneratedvector.h"
0013 
0014 #include "generatedvector.h"
0015 #include "datasource.h"
0016 #include "datacollection.h"
0017 #include "objectstore.h"
0018 
0019 
0020 #include <QXmlStreamAttributes>
0021 
0022 #include "ksttest.h"
0023 
0024 
0025 static Kst::ObjectStore _store;
0026 
0027 void TestGeneratedVector::cleanupTestCase() {
0028   _store.clear();
0029 }
0030 
0031 
0032 void TestGeneratedVector::testGeneratedVector() {
0033 
0034   //basic default constructor values
0035   Kst::GeneratedVectorPtr m1 = Kst::kst_cast<Kst::GeneratedVector>(_store.createObject<Kst::GeneratedVector>());
0036   QCOMPARE(m1->length(), 1);
0037   QCOMPARE(m1->min(), 0.0);
0038   QCOMPARE(m1->max(), 0.0);
0039   QCOMPARE(m1->value(0), &Kst::NOPOINT);
0040   QCOMPARE(m1->value(10), 0.0); //should be outside the boundaries.
0041   QCOMPARE(m1->mean(), &Kst::NOPOINT);
0042 
0043   m1->changeRange(0, 100, 100);
0044   QCOMPARE(m1->length(), 100);
0045 
0046   m1->writeLock();
0047   m1->internalUpdate();
0048   m1->unlock();
0049 
0050   QCOMPARE(m1->length(), 100);
0051   QCOMPARE(m1->min(), 0.0);
0052   QCOMPARE(m1->max(), 100.0);
0053   QCOMPARE(m1->value(0), 0.0);
0054   QCOMPARE(m1->value(99), 100.0);
0055 }
0056 
0057 #ifdef KST_USE_QTEST_MAIN
0058 QTEST_MAIN(TestGeneratedVector)
0059 #endif
0060 
0061 // vim: ts=2 sw=2 et