91 const uint16_t CHANNEL_NUMBER = 123;
92 const uint32_t MS_BUFFER_SIZE = 4096;
93 const uint32_t NS_BUFFER_SIZE = 1024;
94 const uint16_t SAMPLE1 = 0x1234;
95 const uint16_t SAMPLE2 = 0xc3c3;
96 const uint16_t SAMPLE3 = 0xbeef;
97 const uint16_t SAMPLE4 = 0xfe87;
98 const uint16_t SAMPLE5 = 0x5a5a;
99 std::vector<uint8_t> work_buffer(MS_BUFFER_SIZE);
100 std::unique_ptr<dune::NanoSlice> nslice_ptr;
101 std::shared_ptr<dune::NanoSliceWriter> ns_writer_ptr;
106 BOOST_REQUIRE_EQUAL(ms_writer.nanoSliceCount(), 0);
108 ns_writer_ptr = ms_writer.reserveNanoSlice(NS_BUFFER_SIZE);
109 BOOST_REQUIRE(ns_writer_ptr.get() != 0);
110 BOOST_REQUIRE_EQUAL(ms_writer.size(),
112 BOOST_REQUIRE_EQUAL(ms_writer.nanoSliceCount(), 1);
113 if (ns_writer_ptr.get() != 0) {
114 ns_writer_ptr->setChannelNumber(CHANNEL_NUMBER);
115 ns_writer_ptr->addSample(SAMPLE1);
116 ns_writer_ptr->addSample(SAMPLE2);
117 ns_writer_ptr->addSample(SAMPLE3);
118 ns_writer_ptr->addSample(SAMPLE4);
119 ns_writer_ptr->addSample(SAMPLE5);
121 nslice_ptr = ms_writer.nanoSlice(1);
122 BOOST_REQUIRE(nslice_ptr.get() == 0);
123 nslice_ptr = ms_writer.nanoSlice(0);
124 BOOST_REQUIRE(nslice_ptr.get() != 0);
129 ns_writer_ptr = ms_writer.reserveNanoSlice(NS_BUFFER_SIZE);
130 BOOST_REQUIRE(ns_writer_ptr.get() != 0);
134 BOOST_REQUIRE_EQUAL(ms_writer.nanoSliceCount(), 2);
135 if (ns_writer_ptr.get() != 0) {
136 ns_writer_ptr->setChannelNumber(CHANNEL_NUMBER+1);
137 ns_writer_ptr->addSample(SAMPLE5);
138 ns_writer_ptr->addSample(SAMPLE3);
139 ns_writer_ptr->addSample(SAMPLE1);
141 nslice_ptr = ms_writer.nanoSlice(2);
142 BOOST_REQUIRE(nslice_ptr.get() == 0);
143 nslice_ptr = ms_writer.nanoSlice(99);
144 BOOST_REQUIRE(nslice_ptr.get() == 0);
145 nslice_ptr = ms_writer.nanoSlice(0);
146 BOOST_REQUIRE(nslice_ptr.get() != 0);
147 nslice_ptr = ms_writer.nanoSlice(1);
148 BOOST_REQUIRE(nslice_ptr.get() != 0);
153 ns_writer_ptr = ms_writer.reserveNanoSlice(NS_BUFFER_SIZE);
154 BOOST_REQUIRE(ns_writer_ptr.get() != 0);
158 BOOST_REQUIRE_EQUAL(ms_writer.nanoSliceCount(), 3);
159 if (ns_writer_ptr.get() != 0) {
160 ns_writer_ptr->setChannelNumber(CHANNEL_NUMBER+2);
161 ns_writer_ptr->addSample(SAMPLE4);
162 ns_writer_ptr->addSample(SAMPLE5);
164 nslice_ptr = ms_writer.nanoSlice(3);
165 BOOST_REQUIRE(nslice_ptr.get() == 0);
166 nslice_ptr = ms_writer.nanoSlice(99);
167 BOOST_REQUIRE(nslice_ptr.get() == 0);
168 nslice_ptr = ms_writer.nanoSlice(0);
169 BOOST_REQUIRE(nslice_ptr.get() != 0);
170 nslice_ptr = ms_writer.nanoSlice(1);
171 BOOST_REQUIRE(nslice_ptr.get() != 0);
172 nslice_ptr = ms_writer.nanoSlice(2);
173 BOOST_REQUIRE(nslice_ptr.get() != 0);
179 int32_t size_diff = ms_writer.finalize();
184 bool threw_exception =
false;
187 ms_writer.reserveNanoSlice(NS_BUFFER_SIZE);
189 threw_exception =
true;
192 BOOST_REQUIRE_EQUAL(threw_exception,
true);
201 BOOST_REQUIRE_EQUAL(mslice.nanoSliceCount(), 3);
203 nslice_ptr = ms_writer.nanoSlice(0);
204 BOOST_REQUIRE(nslice_ptr.get() != 0);
207 BOOST_REQUIRE_EQUAL(nslice_ptr->channelNumber(), CHANNEL_NUMBER);
208 BOOST_REQUIRE_EQUAL(nslice_ptr->sampleCount(), 5);
209 BOOST_REQUIRE(nslice_ptr->sampleValue(0, value));
210 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
211 BOOST_REQUIRE(nslice_ptr->sampleValue(1, value));
212 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
213 BOOST_REQUIRE(nslice_ptr->sampleValue(2, value));
214 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
215 BOOST_REQUIRE(nslice_ptr->sampleValue(3, value));
216 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
217 BOOST_REQUIRE(nslice_ptr->sampleValue(4, value));
218 BOOST_REQUIRE_EQUAL(value, SAMPLE5);
219 BOOST_REQUIRE(! nslice_ptr->sampleValue(5, value));
220 BOOST_REQUIRE(! nslice_ptr->sampleValue(567, value));
222 nslice_ptr = ms_writer.nanoSlice(1);
223 BOOST_REQUIRE(nslice_ptr.get() != 0);
226 BOOST_REQUIRE_EQUAL(nslice_ptr->channelNumber(), CHANNEL_NUMBER+1);
227 BOOST_REQUIRE_EQUAL(nslice_ptr->sampleCount(), 3);
228 BOOST_REQUIRE(nslice_ptr->sampleValue(0, value));
229 BOOST_REQUIRE_EQUAL(value, SAMPLE5);
230 BOOST_REQUIRE(nslice_ptr->sampleValue(1, value));
231 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
232 BOOST_REQUIRE(nslice_ptr->sampleValue(2, value));
233 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
234 BOOST_REQUIRE(! nslice_ptr->sampleValue(3, value));
236 nslice_ptr = ms_writer.nanoSlice(2);
237 BOOST_REQUIRE(nslice_ptr.get() != 0);
240 BOOST_REQUIRE_EQUAL(nslice_ptr->channelNumber(), CHANNEL_NUMBER+2);
241 BOOST_REQUIRE_EQUAL(nslice_ptr->sampleCount(), 2);
242 BOOST_REQUIRE(nslice_ptr->sampleValue(0, value));
243 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
244 BOOST_REQUIRE(nslice_ptr->sampleValue(1, value));
245 BOOST_REQUIRE_EQUAL(value, SAMPLE5);
246 BOOST_REQUIRE(! nslice_ptr->sampleValue(2, value));
cet::coded_exception< error, detail::translate > exception