14 #pragma GCC diagnostic push 15 #pragma GCC diagnostic ignored "-Wsign-compare" 18 #define BOOST_TEST_MODULE(NanoSlice_t) 22 BOOST_AUTO_TEST_SUITE(NanoSlice_test)
26 const uint16_t CHANNEL_NUMBER = 123;
27 const uint32_t BUFFER_SIZE = 4096;
28 const uint16_t SAMPLE1 = 0x1234;
29 const uint16_t SAMPLE2 = 0xc3c3;
30 const uint16_t SAMPLE3 = 0xbeef;
31 const uint16_t SAMPLE4 = 0xfe87;
32 const uint16_t SAMPLE5 = 0x5a5a;
33 std::vector<uint8_t> work_buffer(BUFFER_SIZE);
47 BOOST_REQUIRE_EQUAL(ns_writer.
channelNumber(), CHANNEL_NUMBER);
49 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE1));
50 BOOST_REQUIRE_EQUAL(ns_writer.
size(),
54 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
58 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE2));
59 BOOST_REQUIRE_EQUAL(ns_writer.
size(),
63 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
65 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
69 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE3));
70 BOOST_REQUIRE_EQUAL(ns_writer.
size(),
74 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
76 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
78 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
82 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE4));
83 BOOST_REQUIRE_EQUAL(ns_writer.
size(),
87 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
89 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
91 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
93 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
100 int32_t size_diff = ns_writer.
finalize();
101 BOOST_REQUIRE_EQUAL(size_diff, BUFFER_SIZE -
103 BOOST_REQUIRE(! ns_writer.
addSample(SAMPLE5));
109 BOOST_REQUIRE_EQUAL(nslice.size(),
111 BOOST_REQUIRE_EQUAL(nslice.channelNumber(), CHANNEL_NUMBER);
112 BOOST_REQUIRE_EQUAL(nslice.sampleCount(), 4);
113 BOOST_REQUIRE(nslice.sampleValue(0, value));
114 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
115 BOOST_REQUIRE(nslice.sampleValue(1, value));
116 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
117 BOOST_REQUIRE(nslice.sampleValue(2, value));
118 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
119 BOOST_REQUIRE(nslice.sampleValue(3, value));
120 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
121 BOOST_REQUIRE(! nslice.sampleValue(4, value));
122 BOOST_REQUIRE(! nslice.sampleValue(567, value));
127 const uint16_t CHANNEL_NUMBER = 456;
128 const uint32_t BUFFER_SIZE = 4096;
129 const uint32_t SMALL_SIZE1 = 1;
130 const uint16_t SAMPLE1 = 0x1234;
131 std::vector<uint8_t> work_buffer(BUFFER_SIZE);
139 BOOST_REQUIRE_EQUAL(ns_writer.
channelNumber(), CHANNEL_NUMBER);
141 BOOST_REQUIRE(! ns_writer.
sampleValue(999, value));
143 BOOST_REQUIRE(! ns_writer.
addSample(SAMPLE1));
146 BOOST_REQUIRE_EQUAL(ns_writer.
channelNumber(), CHANNEL_NUMBER);
150 int32_t size_diff = ns_writer.
finalize();
151 BOOST_REQUIRE_EQUAL(size_diff, 0);
156 const uint16_t CHANNEL_NUMBER = 456;
157 const uint32_t BUFFER_SIZE = 4096;
159 const uint16_t SAMPLE1 = 0x1234;
160 const uint16_t SAMPLE2 = 0xc3c3;
161 std::vector<uint8_t> work_buffer(BUFFER_SIZE);
169 BOOST_REQUIRE_EQUAL(ns_writer.
channelNumber(), CHANNEL_NUMBER);
171 BOOST_REQUIRE(! ns_writer.
sampleValue(999, value));
173 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE1));
174 BOOST_REQUIRE_EQUAL(ns_writer.
size(),
178 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
180 BOOST_REQUIRE(! ns_writer.
sampleValue(999, value));
182 BOOST_REQUIRE(! ns_writer.
addSample(SAMPLE2));
183 BOOST_REQUIRE_EQUAL(ns_writer.
size(),
187 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
191 int32_t size_diff = ns_writer.
finalize();
192 BOOST_REQUIRE_EQUAL(size_diff, 1);
197 const uint16_t CHANNEL_NUMBER = 123;
198 const uint32_t BUFFER_SIZE = 4096;
199 const uint16_t SAMPLE1 = 0x1234;
200 const uint16_t SAMPLE2 = 0xc3c3;
201 const uint16_t SAMPLE3 = 0xbeef;
202 const uint16_t SAMPLE4 = 0xfe87;
203 const uint16_t SAMPLE5 = 0x5a5a;
204 std::vector<uint8_t> work_buffer(BUFFER_SIZE);
210 BOOST_REQUIRE_EQUAL(ns_writer.
channelNumber(), CHANNEL_NUMBER);
211 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE1));
212 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE2));
213 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE3));
214 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE4));
215 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE5));
217 int32_t size_diff = ns_writer.
finalize();
218 BOOST_REQUIRE_EQUAL(size_diff, BUFFER_SIZE -
222 BOOST_REQUIRE_EQUAL(ns_writer_copy.
sampleCount(), 5);
223 BOOST_REQUIRE(ns_writer_copy.
sampleValue(0, value));
224 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
225 BOOST_REQUIRE(ns_writer_copy.
sampleValue(1, value));
226 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
227 BOOST_REQUIRE(ns_writer_copy.
sampleValue(2, value));
228 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
229 BOOST_REQUIRE(ns_writer_copy.
sampleValue(3, value));
230 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
231 BOOST_REQUIRE(ns_writer_copy.
sampleValue(4, value));
232 BOOST_REQUIRE_EQUAL(value, SAMPLE5);
233 BOOST_REQUIRE(! ns_writer.
addSample(SAMPLE5));
237 BOOST_REQUIRE_EQUAL(nslice_copy.
size(),
239 BOOST_REQUIRE_EQUAL(nslice_copy.
channelNumber(), CHANNEL_NUMBER);
242 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
244 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
246 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
248 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
250 BOOST_REQUIRE_EQUAL(value, SAMPLE5);
251 BOOST_REQUIRE(! nslice_copy.
sampleValue(6, value));
252 BOOST_REQUIRE(! nslice_copy.
sampleValue(567, value));
257 const uint16_t CHANNEL_NUMBER = 123;
258 const uint32_t BUFFER_SIZE = 4096;
259 const uint16_t SAMPLE1 = 0x1234;
260 const uint16_t SAMPLE2 = 0xc3c3;
261 const uint16_t SAMPLE3 = 0xbeef;
262 std::vector<uint8_t> work_buffer(BUFFER_SIZE);
268 BOOST_REQUIRE_EQUAL(ns_writer.
channelNumber(), CHANNEL_NUMBER);
269 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE1));
270 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE2));
271 BOOST_REQUIRE(ns_writer.
addSample(SAMPLE3));
273 int32_t size_diff = ns_writer.
finalize();
274 BOOST_REQUIRE_EQUAL(size_diff, BUFFER_SIZE -
284 BOOST_REQUIRE(ns_writer2.
addSample(SAMPLE3));
287 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
298 BOOST_AUTO_TEST_SUITE_END()
300 #pragma GCC diagnostic pop
bool sampleValue(uint32_t index, uint16_t &value) const
Header::sample_count_t sampleCount() const
BOOST_AUTO_TEST_CASE(BaselineTest)
void setChannelNumber(uint16_t channel)
bool addSample(uint16_t value)
Header::nanoslice_size_t size() const
Header::channel_number_t channelNumber() const