Mercurial > hg > svcore
comparison data/model/test/TestSparseModels.h @ 1689:d7b04b0ed056 single-point
Build fix for older Qt
author | Chris Cannam |
---|---|
date | Fri, 05 Apr 2019 13:40:08 +0100 |
parents | 0e9840a381b5 |
children | c077a97d055f |
comparison
equal
deleted
inserted
replaced
1687:1bbea26ea21a | 1689:d7b04b0ed056 |
---|---|
40 private slots: | 40 private slots: |
41 void s1d_empty() { | 41 void s1d_empty() { |
42 SparseOneDimensionalModel m(100, 10, false); | 42 SparseOneDimensionalModel m(100, 10, false); |
43 QCOMPARE(m.isEmpty(), true); | 43 QCOMPARE(m.isEmpty(), true); |
44 QCOMPARE(m.getEventCount(), 0); | 44 QCOMPARE(m.getEventCount(), 0); |
45 QCOMPARE(m.getAllEvents().size(), 0); | 45 QCOMPARE(m.getAllEvents().size(), size_t(0)); |
46 QCOMPARE(m.getStartFrame(), 0); | 46 QCOMPARE(m.getStartFrame(), 0); |
47 QCOMPARE(m.getEndFrame(), 0); | 47 QCOMPARE(m.getEndFrame(), 0); |
48 QCOMPARE(m.getSampleRate(), 100); | 48 QCOMPARE(m.getSampleRate(), 100.0); |
49 QCOMPARE(m.getResolution(), 10); | 49 QCOMPARE(m.getResolution(), 10); |
50 QCOMPARE(m.isSparse(), true); | 50 QCOMPARE(m.isSparse(), true); |
51 | 51 |
52 Event p(10); | 52 Event p(10); |
53 m.add(p); | 53 m.add(p); |
54 m.remove(p); | 54 m.remove(p); |
55 QCOMPARE(m.isEmpty(), true); | 55 QCOMPARE(m.isEmpty(), true); |
56 QCOMPARE(m.getEventCount(), 0); | 56 QCOMPARE(m.getEventCount(), 0); |
57 QCOMPARE(m.getAllEvents().size(), 0); | 57 QCOMPARE(m.getAllEvents().size(), size_t(0)); |
58 QCOMPARE(m.getStartFrame(), 0); | 58 QCOMPARE(m.getStartFrame(), 0); |
59 QCOMPARE(m.getEndFrame(), 0); | 59 QCOMPARE(m.getEndFrame(), 0); |
60 } | 60 } |
61 | 61 |
62 void s1d_extents() { | 62 void s1d_extents() { |
67 QCOMPARE(m.getEventCount(), 1); | 67 QCOMPARE(m.getEventCount(), 1); |
68 Event p2(50); | 68 Event p2(50); |
69 m.add(p2); | 69 m.add(p2); |
70 QCOMPARE(m.isEmpty(), false); | 70 QCOMPARE(m.isEmpty(), false); |
71 QCOMPARE(m.getEventCount(), 2); | 71 QCOMPARE(m.getEventCount(), 2); |
72 QCOMPARE(m.getAllEvents().size(), 2); | 72 QCOMPARE(m.getAllEvents().size(), size_t(2)); |
73 QCOMPARE(*m.getAllEvents().begin(), p1); | 73 QCOMPARE(*m.getAllEvents().begin(), p1); |
74 QCOMPARE(*m.getAllEvents().rbegin(), p2); | 74 QCOMPARE(*m.getAllEvents().rbegin(), p2); |
75 QCOMPARE(m.getStartFrame(), 20); | 75 QCOMPARE(m.getStartFrame(), 20); |
76 QCOMPARE(m.getEndFrame(), 60); | 76 QCOMPARE(m.getEndFrame(), 60); |
77 QCOMPARE(m.containsEvent(p1), true); | 77 QCOMPARE(m.containsEvent(p1), true); |
78 m.remove(p1); | 78 m.remove(p1); |
79 QCOMPARE(m.getEventCount(), 1); | 79 QCOMPARE(m.getEventCount(), 1); |
80 QCOMPARE(m.getAllEvents().size(), 1); | 80 QCOMPARE(m.getAllEvents().size(), size_t(1)); |
81 QCOMPARE(*m.getAllEvents().begin(), p2); | 81 QCOMPARE(*m.getAllEvents().begin(), p2); |
82 QCOMPARE(m.getStartFrame(), 50); | 82 QCOMPARE(m.getStartFrame(), 50); |
83 QCOMPARE(m.getEndFrame(), 60); | 83 QCOMPARE(m.getEndFrame(), 60); |
84 QCOMPARE(m.containsEvent(p1), false); | 84 QCOMPARE(m.containsEvent(p1), false); |
85 } | 85 } |
88 SparseOneDimensionalModel m(100, 10, false); | 88 SparseOneDimensionalModel m(100, 10, false); |
89 Event p1(20), p2(20), p3(50); | 89 Event p1(20), p2(20), p3(50); |
90 m.add(p1); | 90 m.add(p1); |
91 m.add(p2); | 91 m.add(p2); |
92 m.add(p3); | 92 m.add(p3); |
93 QCOMPARE(m.getAllEvents().size(), 3); | 93 QCOMPARE(m.getAllEvents().size(), size_t(3)); |
94 QCOMPARE(*m.getAllEvents().begin(), p1); | 94 QCOMPARE(*m.getAllEvents().begin(), p1); |
95 QCOMPARE(*m.getAllEvents().rbegin(), p3); | 95 QCOMPARE(*m.getAllEvents().rbegin(), p3); |
96 | 96 |
97 // The EventSeries that is used internally is tested more | 97 // The EventSeries that is used internally is tested more |
98 // thoroughly in its own test suite. This is just a check | 98 // thoroughly in its own test suite. This is just a check |
99 auto pp = m.getEventsWithin(20, 10); | 99 auto pp = m.getEventsWithin(20, 10); |
100 QCOMPARE(pp.size(), 2); | 100 QCOMPARE(pp.size(), size_t(2)); |
101 QCOMPARE(*pp.begin(), p1); | 101 QCOMPARE(*pp.begin(), p1); |
102 QCOMPARE(*pp.rbegin(), p2); | 102 QCOMPARE(*pp.rbegin(), p2); |
103 | 103 |
104 pp = m.getEventsWithin(40, 10); | 104 pp = m.getEventsWithin(40, 10); |
105 QCOMPARE(pp.size(), 0); | 105 QCOMPARE(pp.size(), size_t(0)); |
106 | 106 |
107 pp = m.getEventsStartingAt(50); | 107 pp = m.getEventsStartingAt(50); |
108 QCOMPARE(pp.size(), 1); | 108 QCOMPARE(pp.size(), size_t(1)); |
109 QCOMPARE(*pp.begin(), p3); | 109 QCOMPARE(*pp.begin(), p3); |
110 } | 110 } |
111 | 111 |
112 void s1d_xml() { | 112 void s1d_xml() { |
113 SparseOneDimensionalModel m(100, 10, false); | 113 SparseOneDimensionalModel m(100, 10, false); |
145 QCOMPARE(m.getEventCount(), 1); | 145 QCOMPARE(m.getEventCount(), 1); |
146 Event p2(50, 124.3f, 30, 0.9f, "note 2"); | 146 Event p2(50, 124.3f, 30, 0.9f, "note 2"); |
147 m.add(p2); | 147 m.add(p2); |
148 QCOMPARE(m.isEmpty(), false); | 148 QCOMPARE(m.isEmpty(), false); |
149 QCOMPARE(m.getEventCount(), 2); | 149 QCOMPARE(m.getEventCount(), 2); |
150 QCOMPARE(m.getAllEvents().size(), 2); | 150 QCOMPARE(m.getAllEvents().size(), size_t(2)); |
151 QCOMPARE(*m.getAllEvents().begin(), p1); | 151 QCOMPARE(*m.getAllEvents().begin(), p1); |
152 QCOMPARE(*m.getAllEvents().rbegin(), p2); | 152 QCOMPARE(*m.getAllEvents().rbegin(), p2); |
153 QCOMPARE(m.getStartFrame(), 20); | 153 QCOMPARE(m.getStartFrame(), 20); |
154 QCOMPARE(m.getEndFrame(), 80); | 154 QCOMPARE(m.getEndFrame(), 80); |
155 QCOMPARE(m.containsEvent(p1), true); | 155 QCOMPARE(m.containsEvent(p1), true); |
156 QCOMPARE(m.getValueMinimum(), 123.4f); | 156 QCOMPARE(m.getValueMinimum(), 123.4f); |
157 QCOMPARE(m.getValueMaximum(), 124.3f); | 157 QCOMPARE(m.getValueMaximum(), 124.3f); |
158 m.remove(p1); | 158 m.remove(p1); |
159 QCOMPARE(m.getEventCount(), 1); | 159 QCOMPARE(m.getEventCount(), 1); |
160 QCOMPARE(m.getAllEvents().size(), 1); | 160 QCOMPARE(m.getAllEvents().size(), size_t(1)); |
161 QCOMPARE(*m.getAllEvents().begin(), p2); | 161 QCOMPARE(*m.getAllEvents().begin(), p2); |
162 QCOMPARE(m.getStartFrame(), 50); | 162 QCOMPARE(m.getStartFrame(), 50); |
163 QCOMPARE(m.getEndFrame(), 80); | 163 QCOMPARE(m.getEndFrame(), 80); |
164 QCOMPARE(m.containsEvent(p1), false); | 164 QCOMPARE(m.containsEvent(p1), false); |
165 } | 165 } |
171 Event p3(50, 126.3f, 30, 0.9f, "note 3"); | 171 Event p3(50, 126.3f, 30, 0.9f, "note 3"); |
172 m.add(p1); | 172 m.add(p1); |
173 m.add(p2); | 173 m.add(p2); |
174 m.add(p3); | 174 m.add(p3); |
175 | 175 |
176 QCOMPARE(m.getAllEvents().size(), 3); | 176 QCOMPARE(m.getAllEvents().size(), size_t(3)); |
177 QCOMPARE(*m.getAllEvents().begin(), p1); | 177 QCOMPARE(*m.getAllEvents().begin(), p1); |
178 QCOMPARE(*m.getAllEvents().rbegin(), p3); | 178 QCOMPARE(*m.getAllEvents().rbegin(), p3); |
179 | 179 |
180 auto pp = m.getEventsSpanning(20, 10); | 180 auto pp = m.getEventsSpanning(20, 10); |
181 QCOMPARE(pp.size(), 2); | 181 QCOMPARE(pp.size(), size_t(2)); |
182 QCOMPARE(*pp.begin(), p1); | 182 QCOMPARE(*pp.begin(), p1); |
183 QCOMPARE(*pp.rbegin(), p2); | 183 QCOMPARE(*pp.rbegin(), p2); |
184 | 184 |
185 pp = m.getEventsSpanning(30, 20); | 185 pp = m.getEventsSpanning(30, 20); |
186 QCOMPARE(pp.size(), 1); | 186 QCOMPARE(pp.size(), size_t(1)); |
187 QCOMPARE(*pp.begin(), p2); | 187 QCOMPARE(*pp.begin(), p2); |
188 | 188 |
189 pp = m.getEventsSpanning(40, 10); | 189 pp = m.getEventsSpanning(40, 10); |
190 QCOMPARE(pp.size(), 0); | 190 QCOMPARE(pp.size(), size_t(0)); |
191 | 191 |
192 pp = m.getEventsCovering(50); | 192 pp = m.getEventsCovering(50); |
193 QCOMPARE(pp.size(), 1); | 193 QCOMPARE(pp.size(), size_t(1)); |
194 QCOMPARE(*pp.begin(), p3); | 194 QCOMPARE(*pp.begin(), p3); |
195 } | 195 } |
196 | 196 |
197 void note_xml() { | 197 void note_xml() { |
198 NoteModel m(100, 10, false); | 198 NoteModel m(100, 10, false); |