X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=test%2Flogicdatasnapshot.cpp;h=5041c1b327bf689c2a0fa3ecb74c70447d44ab9e;hp=9d647e6cbb3e0510c45f3844ed2aa91f57e67d53;hb=4f767cf7100023341f94fa9f0d1befc5101c3d6d;hpb=910b16ec9fb9bce36311620164eb08218fda29b1 diff --git a/test/logicdatasnapshot.cpp b/test/logicdatasnapshot.cpp index 9d647e6c..5041c1b3 100644 --- a/test/logicdatasnapshot.cpp +++ b/test/logicdatasnapshot.cpp @@ -291,6 +291,7 @@ BOOST_AUTO_TEST_CASE(Pulses) } LogicDataSnapshot s(logic); + delete[] (uint8_t*)logic.data; //----- Check the mip-map -----// // Check mip map level 0 @@ -322,9 +323,10 @@ BOOST_AUTO_TEST_CASE(Pulses) //----- Test get_subsampled_edges at reduced scale -----// s.get_subsampled_edges(edges, 0, Length-1, 16.0f, 2); - BOOST_REQUIRE_EQUAL(edges.size(), Cycles + 1); + BOOST_REQUIRE_EQUAL(edges.size(), Cycles + 2); - for(int i = 0; i < edges.size(); i++) + BOOST_CHECK_EQUAL(0, false); + for(int i = 1; i < edges.size(); i++) BOOST_CHECK_EQUAL(edges[i].second, false); } @@ -340,19 +342,20 @@ BOOST_AUTO_TEST_CASE(LongPulses) //----- Create a LogicDataSnapshot -----// sr_datafeed_logic logic; - logic.unitsize = 1; + logic.unitsize = 8; logic.length = Length; - logic.data = (uint64_t*)new uint8_t[Length]; - uint8_t *p = (uint8_t*)logic.data; + logic.data = (uint64_t*)new uint64_t[Length]; + uint64_t *p = (uint64_t*)logic.data; for(int i = 0; i < Cycles; i++) { for(j = 0; j < PulseWidth; j++) - *p++ = 0xFF; + *p++ = ~0; for(j; j < Period; j++) - *p++ = 0x00; + *p++ = 0; } LogicDataSnapshot s(logic); + delete[] (uint64_t*)logic.data; //----- Check the mip-map -----// // Check mip map level 0 @@ -365,14 +368,14 @@ BOOST_AUTO_TEST_CASE(LongPulses) for(j = 0; i < s._mip_map[0].length && j < 2; j++) { BOOST_TEST_MESSAGE( "Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0xFF); + BOOST_CHECK_EQUAL(s.get_subsample(0, i++), ~0); } for(j; i < s._mip_map[0].length && j < Period/LogicDataSnapshot::MipMapScaleFactor; j++) { BOOST_TEST_MESSAGE( "Testing mip_map[0].data[" << i << "]"); - BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0x00); + BOOST_CHECK_EQUAL(s.get_subsample(0, i++), 0); } } @@ -402,9 +405,14 @@ BOOST_AUTO_TEST_CASE(LongPulses) edges.clear(); s.get_subsampled_edges(edges, 0, Length-1, 17.0f, 2); - for(int i = 0; i < Cycles; i++) { - BOOST_CHECK_EQUAL(edges[i].first, i * Period); - BOOST_CHECK_EQUAL(edges[i].second, false); + BOOST_CHECK_EQUAL(edges[0].first, 0); + BOOST_CHECK_EQUAL(edges[0].second, true); + BOOST_CHECK_EQUAL(edges[1].first, 16); + BOOST_CHECK_EQUAL(edges[1].second, false); + + for(int i = 1; i < Cycles; i++) { + BOOST_CHECK_EQUAL(edges[i+1].first, i * Period); + BOOST_CHECK_EQUAL(edges[i+1].second, false); } BOOST_CHECK_EQUAL(edges.back().first, Length-1);