]> sigrok.org Git - pulseview.git/blame - test/data/logicsnapshot.cpp
tests: Add check for handling of wide data (16 probes)
[pulseview.git] / test / data / logicsnapshot.cpp
CommitLineData
4ceab49a 1/*
b3f22de0 2 * This file is part of the PulseView project.
4ceab49a
JH
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
cef18fc6
JH
21#include <extdef.h>
22
8743e7cb
JH
23#define __STDC_LIMIT_MACROS
24#include <stdint.h>
25
4ceab49a
JH
26#include <boost/test/unit_test.hpp>
27
1b1ec774 28#include "../../pv/data/logicsnapshot.h"
4ceab49a 29
0b02e057
JH
30using namespace std;
31
1b1ec774 32using pv::data::LogicSnapshot;
51e77110 33
1b1ec774 34BOOST_AUTO_TEST_SUITE(LogicSnapshotTest)
ecda6ca9 35
1b1ec774 36void push_logic(LogicSnapshot &s, unsigned int length, uint8_t value)
4ceab49a
JH
37{
38 sr_datafeed_logic logic;
39 logic.unitsize = 1;
40 logic.length = length;
41 logic.data = new uint8_t[length];
42 memset(logic.data, value, length * logic.unitsize);
43 s.append_payload(logic);
44 delete[] (uint8_t*)logic.data;
45}
46
8743e7cb
JH
47BOOST_AUTO_TEST_CASE(Pow2)
48{
1b1ec774
JH
49 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(0, 0), 0);
50 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(1, 0), 1);
51 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(2, 0), 2);
8743e7cb
JH
52
53 BOOST_CHECK_EQUAL(
1b1ec774 54 LogicSnapshot::pow2_ceil(INT64_MIN, 0), INT64_MIN);
8743e7cb 55 BOOST_CHECK_EQUAL(
1b1ec774 56 LogicSnapshot::pow2_ceil(INT64_MAX, 0), INT64_MAX);
8743e7cb 57
1b1ec774
JH
58 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(0, 1), 0);
59 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(1, 1), 2);
60 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(2, 1), 2);
61 BOOST_CHECK_EQUAL(LogicSnapshot::pow2_ceil(3, 1), 4);
8743e7cb
JH
62}
63
ecda6ca9 64BOOST_AUTO_TEST_CASE(Basic)
4ceab49a 65{
1b1ec774 66 // Create an empty LogicSnapshot object
4ceab49a
JH
67 sr_datafeed_logic logic;
68 logic.length = 0;
69 logic.unitsize = 1;
70 logic.data = NULL;
71
1b1ec774 72 LogicSnapshot s(logic);
4ceab49a 73
1b1ec774 74 //----- Test LogicSnapshot::push_logic -----//
0b02e057 75
4ceab49a 76 BOOST_CHECK(s.get_sample_count() == 0);
1b1ec774 77 for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++)
4ceab49a 78 {
1b1ec774 79 const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
4ceab49a
JH
80 BOOST_CHECK_EQUAL(m.length, 0);
81 BOOST_CHECK_EQUAL(m.data_length, 0);
82 BOOST_CHECK(m.data == NULL);
83 }
84
85 // Push 8 samples of all zeros
86 push_logic(s, 8, 0);
87
88 BOOST_CHECK(s.get_sample_count() == 8);
89
90 // There should not be enough samples to have a single mip map sample
1b1ec774 91 for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++)
4ceab49a 92 {
1b1ec774 93 const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
4ceab49a
JH
94 BOOST_CHECK_EQUAL(m.length, 0);
95 BOOST_CHECK_EQUAL(m.data_length, 0);
96 BOOST_CHECK(m.data == NULL);
97 }
98
99 // Push 8 samples of 0x11s to bring the total up to 16
100 push_logic(s, 8, 0x11);
101
102 // There should now be enough data for exactly one sample
103 // in mip map level 0, and that sample should be 0
1b1ec774 104 const LogicSnapshot::MipMapLevel &m0 = s._mip_map[0];
4ceab49a 105 BOOST_CHECK_EQUAL(m0.length, 1);
1b1ec774 106 BOOST_CHECK_EQUAL(m0.data_length, LogicSnapshot::MipMapDataUnit);
4ceab49a
JH
107 BOOST_REQUIRE(m0.data != NULL);
108 BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[0], 0x11);
109
110 // The higher levels should still be empty
1b1ec774 111 for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++)
4ceab49a 112 {
1b1ec774 113 const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
4ceab49a
JH
114 BOOST_CHECK_EQUAL(m.length, 0);
115 BOOST_CHECK_EQUAL(m.data_length, 0);
116 BOOST_CHECK(m.data == NULL);
117 }
118
119 // Push 240 samples of all zeros to bring the total up to 256
120 push_logic(s, 240, 0);
121
122 BOOST_CHECK_EQUAL(m0.length, 16);
1b1ec774 123 BOOST_CHECK_EQUAL(m0.data_length, LogicSnapshot::MipMapDataUnit);
4ceab49a
JH
124
125 BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[1], 0x11);
333d5bbc 126 for (unsigned int i = 2; i < m0.length; i++)
4ceab49a
JH
127 BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[i], 0);
128
1b1ec774 129 const LogicSnapshot::MipMapLevel &m1 = s._mip_map[1];
4ceab49a 130 BOOST_CHECK_EQUAL(m1.length, 1);
1b1ec774 131 BOOST_CHECK_EQUAL(m1.data_length, LogicSnapshot::MipMapDataUnit);
4ceab49a
JH
132 BOOST_REQUIRE(m1.data != NULL);
133 BOOST_CHECK_EQUAL(((uint8_t*)m1.data)[0], 0x11);
0b02e057 134
1b1ec774 135 //----- Test LogicSnapshot::get_subsampled_edges -----//
0b02e057
JH
136
137 // Test a full view at full zoom.
1b1ec774 138 vector<LogicSnapshot::EdgePair> edges;
0b02e057
JH
139 s.get_subsampled_edges(edges, 0, 255, 1, 0);
140 BOOST_REQUIRE_EQUAL(edges.size(), 4);
141
142 BOOST_CHECK_EQUAL(edges[0].first, 0);
143 BOOST_CHECK_EQUAL(edges[1].first, 8);
144 BOOST_CHECK_EQUAL(edges[2].first, 16);
145 BOOST_CHECK_EQUAL(edges[3].first, 255);
146
147 // Test a subset at high zoom
148 edges.clear();
149 s.get_subsampled_edges(edges, 6, 17, 0.05f, 0);
150 BOOST_REQUIRE_EQUAL(edges.size(), 4);
151
152 BOOST_CHECK_EQUAL(edges[0].first, 6);
153 BOOST_CHECK_EQUAL(edges[1].first, 8);
154 BOOST_CHECK_EQUAL(edges[2].first, 16);
155 BOOST_CHECK_EQUAL(edges[3].first, 17);
4ceab49a 156}
ecda6ca9
JH
157
158BOOST_AUTO_TEST_CASE(LargeData)
159{
160 uint8_t prev_sample;
38f5609e 161 const unsigned int Length = 1000000;
ecda6ca9
JH
162
163 sr_datafeed_logic logic;
164 logic.unitsize = 1;
165 logic.length = Length;
166 logic.data = new uint8_t[Length];
167 uint8_t *data = (uint8_t*)logic.data;
168
333d5bbc 169 for (unsigned int i = 0; i < Length; i++)
ecda6ca9
JH
170 *data++ = (uint8_t)(i >> 8);
171
1b1ec774 172 LogicSnapshot s(logic);
ecda6ca9
JH
173 delete[] (uint8_t*)logic.data;
174
175 BOOST_CHECK(s.get_sample_count() == Length);
176
177 // Check mip map level 0
178 BOOST_CHECK_EQUAL(s._mip_map[0].length, 62500);
179 BOOST_CHECK_EQUAL(s._mip_map[0].data_length,
1b1ec774 180 LogicSnapshot::MipMapDataUnit);
ecda6ca9
JH
181 BOOST_REQUIRE(s._mip_map[0].data != NULL);
182
183 prev_sample = 0;
333d5bbc 184 for (unsigned int i = 0; i < s._mip_map[0].length;)
ecda6ca9
JH
185 {
186 BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
187
188 const uint8_t sample = (uint8_t)((i*16) >> 8);
b2bcbe51 189 BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF,
ecda6ca9
JH
190 prev_sample ^ sample);
191 prev_sample = sample;
192
333d5bbc 193 for (int j = 1; i < s._mip_map[0].length && j < 16; j++)
ecda6ca9
JH
194 {
195 BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
b2bcbe51 196 BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0);
ecda6ca9
JH
197 }
198 }
199
200 // Check mip map level 1
201 BOOST_CHECK_EQUAL(s._mip_map[1].length, 3906);
202 BOOST_CHECK_EQUAL(s._mip_map[1].data_length,
1b1ec774 203 LogicSnapshot::MipMapDataUnit);
ecda6ca9
JH
204 BOOST_REQUIRE(s._mip_map[1].data != NULL);
205
206 prev_sample = 0;
333d5bbc 207 for (unsigned int i = 0; i < s._mip_map[1].length; i++)
ecda6ca9
JH
208 {
209 BOOST_TEST_MESSAGE("Testing mip_map[1].data[" << i << "]");
210
211 const uint8_t sample = i;
212 const uint8_t expected = sample ^ prev_sample;
213 prev_sample = i;
214
b2bcbe51 215 BOOST_CHECK_EQUAL(s.get_subsample(1, i) & 0xFF, expected);
ecda6ca9
JH
216 }
217
218 // Check mip map level 2
219 BOOST_CHECK_EQUAL(s._mip_map[2].length, 244);
220 BOOST_CHECK_EQUAL(s._mip_map[2].data_length,
1b1ec774 221 LogicSnapshot::MipMapDataUnit);
ecda6ca9
JH
222 BOOST_REQUIRE(s._mip_map[2].data != NULL);
223
224 prev_sample = 0;
333d5bbc 225 for (unsigned int i = 0; i < s._mip_map[2].length; i++)
ecda6ca9
JH
226 {
227 BOOST_TEST_MESSAGE("Testing mip_map[2].data[" << i << "]");
228
229 const uint8_t sample = i << 4;
230 const uint8_t expected = (sample ^ prev_sample) | 0x0F;
231 prev_sample = sample;
232
b2bcbe51 233 BOOST_CHECK_EQUAL(s.get_subsample(2, i) & 0xFF, expected);
ecda6ca9
JH
234 }
235
236 // Check mip map level 3
237 BOOST_CHECK_EQUAL(s._mip_map[3].length, 15);
238 BOOST_CHECK_EQUAL(s._mip_map[3].data_length,
1b1ec774 239 LogicSnapshot::MipMapDataUnit);
ecda6ca9
JH
240 BOOST_REQUIRE(s._mip_map[3].data != NULL);
241
333d5bbc 242 for (unsigned int i = 0; i < s._mip_map[3].length; i++)
ecda6ca9
JH
243 BOOST_CHECK_EQUAL(*((uint8_t*)s._mip_map[3].data + i),
244 0xFF);
245
246 // Check the higher levels
1b1ec774 247 for (unsigned int i = 4; i < LogicSnapshot::ScaleStepCount; i++)
ecda6ca9 248 {
1b1ec774 249 const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
ecda6ca9
JH
250 BOOST_CHECK_EQUAL(m.length, 0);
251 BOOST_CHECK_EQUAL(m.data_length, 0);
252 BOOST_CHECK(m.data == NULL);
253 }
254
1b1ec774 255 //----- Test LogicSnapshot::get_subsampled_edges -----//
ac7aa636 256 // Check in normal case
1b1ec774 257 vector<LogicSnapshot::EdgePair> edges;
ecda6ca9 258 s.get_subsampled_edges(edges, 0, Length-1, 1, 7);
ecda6ca9 259
39f6e56e
JH
260 BOOST_CHECK_EQUAL(edges.size(), 32);
261
333d5bbc 262 for (unsigned int i = 0; i < edges.size() - 1; i++)
ecda6ca9 263 {
39f6e56e
JH
264 BOOST_CHECK_EQUAL(edges[i].first, i * 32768);
265 BOOST_CHECK_EQUAL(edges[i].second, i & 1);
ecda6ca9
JH
266 }
267
39f6e56e 268 BOOST_CHECK_EQUAL(edges[31].first, 999999);
ac7aa636
JH
269
270 // Check in very low zoom case
271 edges.clear();
272 s.get_subsampled_edges(edges, 0, Length-1, 50e6f, 7);
273
274 BOOST_CHECK_EQUAL(edges.size(), 2);
ecda6ca9
JH
275}
276
3db297c4
JH
277BOOST_AUTO_TEST_CASE(Pulses)
278{
279 const int Cycles = 3;
280 const int Period = 64;
281 const int Length = Cycles * Period;
282
1b1ec774 283 vector<LogicSnapshot::EdgePair> edges;
3db297c4 284
1b1ec774 285 //----- Create a LogicSnapshot -----//
3db297c4
JH
286 sr_datafeed_logic logic;
287 logic.unitsize = 1;
288 logic.length = Length;
289 logic.data = (uint64_t*)new uint8_t[Length];
290 uint8_t *p = (uint8_t*)logic.data;
291
333d5bbc 292 for (int i = 0; i < Cycles; i++) {
3db297c4 293 *p++ = 0xFF;
333d5bbc 294 for (int j = 1; j < Period; j++)
3db297c4
JH
295 *p++ = 0x00;
296 }
297
1b1ec774 298 LogicSnapshot s(logic);
821f23af 299 delete[] (uint8_t*)logic.data;
3db297c4
JH
300
301 //----- Check the mip-map -----//
302 // Check mip map level 0
303 BOOST_CHECK_EQUAL(s._mip_map[0].length, 12);
304 BOOST_CHECK_EQUAL(s._mip_map[0].data_length,
1b1ec774 305 LogicSnapshot::MipMapDataUnit);
3db297c4
JH
306 BOOST_REQUIRE(s._mip_map[0].data != NULL);
307
333d5bbc 308 for (unsigned int i = 0; i < s._mip_map[0].length;) {
3db297c4
JH
309 BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
310 BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0xFF);
311
333d5bbc 312 for (int j = 1;
3db297c4 313 i < s._mip_map[0].length &&
1b1ec774 314 j < Period/LogicSnapshot::MipMapScaleFactor; j++) {
3db297c4
JH
315 BOOST_TEST_MESSAGE(
316 "Testing mip_map[0].data[" << i << "]");
317 BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0x00);
318 }
319 }
320
321 // Check the higher levels are all inactive
1b1ec774
JH
322 for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) {
323 const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
3db297c4
JH
324 BOOST_CHECK_EQUAL(m.length, 0);
325 BOOST_CHECK_EQUAL(m.data_length, 0);
326 BOOST_CHECK(m.data == NULL);
327 }
328
329 //----- Test get_subsampled_edges at reduced scale -----//
330 s.get_subsampled_edges(edges, 0, Length-1, 16.0f, 2);
7d0d64f9 331 BOOST_REQUIRE_EQUAL(edges.size(), Cycles + 2);
3db297c4 332
7d0d64f9 333 BOOST_CHECK_EQUAL(0, false);
333d5bbc 334 for (unsigned int i = 1; i < edges.size(); i++)
3db297c4
JH
335 BOOST_CHECK_EQUAL(edges[i].second, false);
336}
337
910b16ec
JH
338BOOST_AUTO_TEST_CASE(LongPulses)
339{
340 const int Cycles = 3;
341 const int Period = 64;
342 const int PulseWidth = 16;
343 const int Length = Cycles * Period;
344
345 int j;
1b1ec774 346 vector<LogicSnapshot::EdgePair> edges;
910b16ec 347
1b1ec774 348 //----- Create a LogicSnapshot -----//
910b16ec 349 sr_datafeed_logic logic;
4f767cf7 350 logic.unitsize = 8;
910b16ec 351 logic.length = Length;
4f767cf7
JH
352 logic.data = (uint64_t*)new uint64_t[Length];
353 uint64_t *p = (uint64_t*)logic.data;
910b16ec 354
333d5bbc
UH
355 for (int i = 0; i < Cycles; i++) {
356 for (j = 0; j < PulseWidth; j++)
4f767cf7 357 *p++ = ~0;
333d5bbc 358 for (; j < Period; j++)
4f767cf7 359 *p++ = 0;
910b16ec
JH
360 }
361
1b1ec774 362 LogicSnapshot s(logic);
ba3c4dae 363 delete[] (uint64_t*)logic.data;
910b16ec
JH
364
365 //----- Check the mip-map -----//
366 // Check mip map level 0
367 BOOST_CHECK_EQUAL(s._mip_map[0].length, 12);
368 BOOST_CHECK_EQUAL(s._mip_map[0].data_length,
1b1ec774 369 LogicSnapshot::MipMapDataUnit);
910b16ec
JH
370 BOOST_REQUIRE(s._mip_map[0].data != NULL);
371
333d5bbc
UH
372 for (unsigned int i = 0; i < s._mip_map[0].length;) {
373 for (j = 0; i < s._mip_map[0].length && j < 2; j++) {
910b16ec
JH
374 BOOST_TEST_MESSAGE(
375 "Testing mip_map[0].data[" << i << "]");
4f767cf7 376 BOOST_CHECK_EQUAL(s.get_subsample(0, i++), ~0);
910b16ec
JH
377 }
378
333d5bbc 379 for (; i < s._mip_map[0].length &&
1b1ec774 380 j < Period/LogicSnapshot::MipMapScaleFactor; j++) {
910b16ec
JH
381 BOOST_TEST_MESSAGE(
382 "Testing mip_map[0].data[" << i << "]");
4f767cf7 383 BOOST_CHECK_EQUAL(s.get_subsample(0, i++), 0);
910b16ec
JH
384 }
385 }
386
387 // Check the higher levels are all inactive
1b1ec774
JH
388 for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) {
389 const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
910b16ec
JH
390 BOOST_CHECK_EQUAL(m.length, 0);
391 BOOST_CHECK_EQUAL(m.data_length, 0);
392 BOOST_CHECK(m.data == NULL);
393 }
394
395 //----- Test get_subsampled_edges at a full scale -----//
396 s.get_subsampled_edges(edges, 0, Length-1, 16.0f, 2);
397 BOOST_REQUIRE_EQUAL(edges.size(), Cycles * 2 + 1);
398
333d5bbc 399 for (int i = 0; i < Cycles; i++) {
910b16ec
JH
400 BOOST_CHECK_EQUAL(edges[i*2].first, i * Period);
401 BOOST_CHECK_EQUAL(edges[i*2].second, true);
402 BOOST_CHECK_EQUAL(edges[i*2+1].first, i * Period + PulseWidth);
403 BOOST_CHECK_EQUAL(edges[i*2+1].second, false);
404 }
405
406 BOOST_CHECK_EQUAL(edges.back().first, Length-1);
407 BOOST_CHECK_EQUAL(edges.back().second, false);
408
409 //----- Test get_subsampled_edges at a simplified scale -----//
410 edges.clear();
411 s.get_subsampled_edges(edges, 0, Length-1, 17.0f, 2);
412
7d0d64f9
JH
413 BOOST_CHECK_EQUAL(edges[0].first, 0);
414 BOOST_CHECK_EQUAL(edges[0].second, true);
415 BOOST_CHECK_EQUAL(edges[1].first, 16);
416 BOOST_CHECK_EQUAL(edges[1].second, false);
417
333d5bbc 418 for (int i = 1; i < Cycles; i++) {
7d0d64f9
JH
419 BOOST_CHECK_EQUAL(edges[i+1].first, i * Period);
420 BOOST_CHECK_EQUAL(edges[i+1].second, false);
910b16ec
JH
421 }
422
423 BOOST_CHECK_EQUAL(edges.back().first, Length-1);
424 BOOST_CHECK_EQUAL(edges.back().second, false);
425}
426
a126c277
JH
427BOOST_AUTO_TEST_CASE(LisaMUsbHid)
428{
429 /* This test was created from the beginning of the USB_DM signal in
430 * sigrok-dumps-usb/lisa_m_usbhid/lisa_m_usbhid.sr
431 */
432
433 const int Edges[] = {
434 7028, 7033, 7036, 7041, 7044, 7049, 7053, 7066, 7073, 7079,
435 7086, 7095, 7103, 7108, 7111, 7116, 7119, 7124, 7136, 7141,
436 7148, 7162, 7500
437 };
438 const int Length = Edges[countof(Edges) - 1];
439
440 bool state = false;
441 int lastEdgePos = 0;
442
1b1ec774 443 //----- Create a LogicSnapshot -----//
a126c277
JH
444 sr_datafeed_logic logic;
445 logic.unitsize = 1;
446 logic.length = Length;
447 logic.data = new uint8_t[Length];
448 uint8_t *data = (uint8_t*)logic.data;
449
333d5bbc 450 for (unsigned int i = 0; i < countof(Edges); i++) {
a126c277
JH
451 const int edgePos = Edges[i];
452 memset(&data[lastEdgePos], state ? 0x02 : 0,
453 edgePos - lastEdgePos - 1);
454
455 lastEdgePos = edgePos;
456 state = !state;
457 }
458
1b1ec774 459 LogicSnapshot s(logic);
a126c277
JH
460 delete[] (uint64_t*)logic.data;
461
1b1ec774 462 vector<LogicSnapshot::EdgePair> edges;
a126c277
JH
463
464
465 /* The trailing edge of the pulse train is falling in the source data.
466 * Check this is always true at different scales
467 */
468
469 edges.clear();
470 s.get_subsampled_edges(edges, 0, Length-1, 33.333332f, 1);
471 BOOST_CHECK_EQUAL(edges[edges.size() - 2].second, false);
472}
473
6092d96f
AG
474/*
475 * This test checks the rendering of wide data (more than 8 probes)
476 * Probe signals are either all-high, or all-low, but are interleaved such that
477 * they would toggle during every sample if treated like 8 probes.
478 * The packet contains a large number of samples, so the mipmap generation kicks
479 * in.
480 *
481 * The signals should not toggle (have exactly two edges: the start and end)
482 */
483BOOST_AUTO_TEST_CASE(WideData)
484{
485 const int Length = 512<<10;
486 uint16_t *data = new uint16_t[Length];
487
488 sr_datafeed_logic logic;
489 logic.unitsize = sizeof(data[0]);
490 logic.length = Length * sizeof(data[0]);
491 logic.data = data;
492
493 for(int i = 0; i < Length; i++)
494 data[i] = 0x0FF0;
495
496 LogicSnapshot s(logic);
497
498 vector<LogicSnapshot::EdgePair> edges;
499
500 edges.clear();
501 s.get_subsampled_edges(edges, 0, Length-1, 1, 0);
502 BOOST_CHECK_EQUAL(edges.size(), 2);
503
504 edges.clear();
505 s.get_subsampled_edges(edges, 0, Length-1, 1, 8);
506 BOOST_CHECK_EQUAL(edges.size(), 2);
507
508 // Cleanup
509 delete [] data;
510}
a126c277 511
ecda6ca9 512BOOST_AUTO_TEST_SUITE_END()