MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

DSView/test/data/analogsnapshot.cpp:50–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50BOOST_AUTO_TEST_CASE(Basic)
51{
52 // Create an empty AnalogSnapshot object
53 sr_datafeed_analog analog;
54 analog.num_samples = 0;
55 analog.data = NULL;
56
57 AnalogSnapshot s(analog);
58
59 //----- Test AnalogSnapshot::push_analog -----//
60
61 BOOST_CHECK(s.get_sample_count() == 0);
62 for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++)
63 {
64 const AnalogSnapshot::Envelope &m = s._envelope_levels[i];
65 BOOST_CHECK_EQUAL(m.length, 0);
66 BOOST_CHECK_EQUAL(m.data_length, 0);
67 BOOST_CHECK(m.samples == NULL);
68 }
69
70 // Push 8 samples of all zeros
71 push_analog(s, 8, 0.0f);
72
73 BOOST_CHECK(s.get_sample_count() == 8);
74
75 // There should not be enough samples to have a single mip map sample
76 for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++)
77 {
78 const AnalogSnapshot::Envelope &m = s._envelope_levels[i];
79 BOOST_CHECK_EQUAL(m.length, 0);
80 BOOST_CHECK_EQUAL(m.data_length, 0);
81 BOOST_CHECK(m.samples == NULL);
82 }
83
84 // Push 8 samples of 1.0s to bring the total up to 16
85 push_analog(s, 8, 1.0f);
86
87 // There should now be enough data for exactly one sample
88 // in mip map level 0, and that sample should be 0
89 const AnalogSnapshot::Envelope &e0 = s._envelope_levels[0];
90 BOOST_CHECK_EQUAL(e0.length, 1);
91 BOOST_CHECK_EQUAL(e0.data_length, AnalogSnapshot::EnvelopeDataUnit);
92 BOOST_REQUIRE(e0.samples != NULL);
93 BOOST_CHECK_EQUAL(e0.samples[0].min, 0.0f);
94 BOOST_CHECK_EQUAL(e0.samples[0].max, 1.0f);
95
96 // The higher levels should still be empty
97 for (unsigned int i = 1; i < AnalogSnapshot::ScaleStepCount; i++)
98 {
99 const AnalogSnapshot::Envelope &m = s._envelope_levels[i];
100 BOOST_CHECK_EQUAL(m.length, 0);
101 BOOST_CHECK_EQUAL(m.data_length, 0);
102 BOOST_CHECK(m.samples == NULL);
103 }
104
105 // Push 240 samples of all zeros to bring the total up to 256
106 push_analog(s, 240, -1.0f);
107

Callers

nothing calls this directly

Calls 2

push_analogFunction · 0.85
get_sample_countMethod · 0.80

Tested by

no test coverage detected