File: testgeneratedmatrix.cpp

package info (click to toggle)
kst 2.0.8-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 30,748 kB
  • sloc: cpp: 97,086; ansic: 13,364; python: 2,970; sh: 761; yacc: 184; lex: 143; makefile: 141; javascript: 122; perl: 30; xml: 30
file content (64 lines) | stat: -rw-r--r-- 1,999 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/***************************************************************************
 *                                                                         *
 *   copyright : (C) 2007 The University of Toronto                        *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "testgeneratedmatrix.h"

#include <QtTest>

#include <generatedmatrix.h>
#include <datasource.h>
#include <math_kst.h>
#include <datacollection.h>
#include <objectstore.h>

#include <QXmlStreamAttributes>

static Kst::ObjectStore _store;

void TestGeneratedMatrix::cleanupTestCase() {
  _store.clear();
}


void TestGeneratedMatrix::testGeneratedMatrix() {
  bool ok = true;

  //basic default constructor values
  Kst::GeneratedMatrixPtr m1 = Kst::kst_cast<Kst::GeneratedMatrix>(_store.createObject<Kst::GeneratedMatrix>());
  QCOMPARE(m1->sampleCount(), 1);
  QCOMPARE(m1->minValue(), 0.0);
  QCOMPARE(m1->maxValue(), 0.0);
  QCOMPARE(m1->value(0, 0, &ok), 0.0);
  QVERIFY(ok);
  QCOMPARE(m1->value(10, 10, &ok), 0.0); //should be outside the boundaries.
  QVERIFY(!ok);
  QCOMPARE(m1->meanValue(), 0.0);

  m1->change(10, 10, 0, 0, 1, 1, 0, 100, 0);

  m1->writeLock();
  m1->internalUpdate();
  m1->unlock();

  QCOMPARE(m1->sampleCount(), 100);
  QCOMPARE(m1->minValue(), 0.0);
  QCOMPARE(m1->maxValue(), 100.0);
  QCOMPARE(m1->value(0, 0, &ok), 0.0);
  QVERIFY(ok);
  QCOMPARE(m1->value(0, 9, &ok), 100.0);
  QVERIFY(ok);
}

#ifdef KST_USE_QTEST_MAIN
QTEST_MAIN(TestGeneratedMatrix)
#endif

// vim: ts=2 sw=2 et