Mercurial > hg > svcore
comparison base/test/TestPointSeries.h @ 1612:23a29e5dc0e9 single-point
Start implementing & testing PointSeries
author | Chris Cannam |
---|---|
date | Wed, 06 Mar 2019 16:24:23 +0000 |
parents | |
children | 2e14a7876945 |
comparison
equal
deleted
inserted
replaced
1611:b2f32c554199 | 1612:23a29e5dc0e9 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 | |
8 This program is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU General Public License as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #ifndef TEST_POINT_SERIES_H | |
16 #define TEST_POINT_SERIES_H | |
17 | |
18 #include "../PointSeries.h" | |
19 | |
20 #include <QObject> | |
21 #include <QtTest> | |
22 | |
23 #include <iostream> | |
24 | |
25 using namespace std; | |
26 | |
27 class TestPointSeries : public QObject | |
28 { | |
29 Q_OBJECT | |
30 | |
31 private slots: | |
32 void empty() { | |
33 | |
34 PointSeries s; | |
35 QCOMPARE(s.isEmpty(), true); | |
36 QCOMPARE(s.count(), 0); | |
37 | |
38 Point p(10, QString()); | |
39 QCOMPARE(s.contains(p), false); | |
40 QCOMPARE(s.getPointsSpanning(400), PointVector()); | |
41 } | |
42 | |
43 void singlePoint() { | |
44 | |
45 PointSeries s; | |
46 Point p(10, QString()); | |
47 s.add(p); | |
48 QCOMPARE(s.isEmpty(), false); | |
49 QCOMPARE(s.count(), 1); | |
50 QCOMPARE(s.contains(p), true); | |
51 | |
52 s.remove(p); | |
53 QCOMPARE(s.isEmpty(), true); | |
54 QCOMPARE(s.contains(p), false); | |
55 } | |
56 | |
57 void singlePointSpan() { | |
58 | |
59 PointSeries s; | |
60 Point p(10, QString()); | |
61 s.add(p); | |
62 PointVector span; | |
63 span.push_back(p); | |
64 QCOMPARE(s.getPointsSpanning(10), span); | |
65 QCOMPARE(s.getPointsSpanning(11), PointVector()); | |
66 QCOMPARE(s.getPointsSpanning(9), PointVector()); | |
67 } | |
68 | |
69 void singlePointWithDurationSpan() { | |
70 | |
71 PointSeries s; | |
72 Point p(10, 1.0, 20, QString()); | |
73 s.add(p); | |
74 PointVector span; | |
75 span.push_back(p); | |
76 QCOMPARE(s.getPointsSpanning(10), span); | |
77 QCOMPARE(s.getPointsSpanning(11), span); | |
78 QCOMPARE(s.getPointsSpanning(29), span); | |
79 QCOMPARE(s.getPointsSpanning(30), PointVector()); | |
80 QCOMPARE(s.getPointsSpanning(9), PointVector()); | |
81 } | |
82 | |
83 }; | |
84 | |
85 #endif |