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);
41 BOOST_REQUIRE_EQUAL(ns_writer.sampleCount(), 0);
42 BOOST_REQUIRE_EQUAL(ns_writer.channelNumber(), 0);
43 BOOST_REQUIRE(! ns_writer.sampleValue(0, value));
44 BOOST_REQUIRE(! ns_writer.sampleValue(999, value));
46 ns_writer.setChannelNumber(CHANNEL_NUMBER);
47 BOOST_REQUIRE_EQUAL(ns_writer.channelNumber(), CHANNEL_NUMBER);
49 BOOST_REQUIRE(ns_writer.addSample(SAMPLE1));
50 BOOST_REQUIRE_EQUAL(ns_writer.size(),
52 BOOST_REQUIRE_EQUAL(ns_writer.sampleCount(), 1);
53 BOOST_REQUIRE(ns_writer.sampleValue(0, value));
54 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
55 BOOST_REQUIRE(! ns_writer.sampleValue(1, value));
56 BOOST_REQUIRE(! ns_writer.sampleValue(999, value));
58 BOOST_REQUIRE(ns_writer.addSample(SAMPLE2));
59 BOOST_REQUIRE_EQUAL(ns_writer.size(),
61 BOOST_REQUIRE_EQUAL(ns_writer.sampleCount(), 2);
62 BOOST_REQUIRE(ns_writer.sampleValue(0, value));
63 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
64 BOOST_REQUIRE(ns_writer.sampleValue(1, value));
65 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
66 BOOST_REQUIRE(! ns_writer.sampleValue(2, value));
67 BOOST_REQUIRE(! ns_writer.sampleValue(101, value));
69 BOOST_REQUIRE(ns_writer.addSample(SAMPLE3));
70 BOOST_REQUIRE_EQUAL(ns_writer.size(),
72 BOOST_REQUIRE_EQUAL(ns_writer.sampleCount(), 3);
73 BOOST_REQUIRE(ns_writer.sampleValue(0, value));
74 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
75 BOOST_REQUIRE(ns_writer.sampleValue(1, value));
76 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
77 BOOST_REQUIRE(ns_writer.sampleValue(2, value));
78 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
79 BOOST_REQUIRE(! ns_writer.sampleValue(3, value));
80 BOOST_REQUIRE(! ns_writer.sampleValue(101, value));
82 BOOST_REQUIRE(ns_writer.addSample(SAMPLE4));
83 BOOST_REQUIRE_EQUAL(ns_writer.size(),
85 BOOST_REQUIRE_EQUAL(ns_writer.sampleCount(), 4);
86 BOOST_REQUIRE(ns_writer.sampleValue(0, value));
87 BOOST_REQUIRE_EQUAL(value, SAMPLE1);
88 BOOST_REQUIRE(ns_writer.sampleValue(1, value));
89 BOOST_REQUIRE_EQUAL(value, SAMPLE2);
90 BOOST_REQUIRE(ns_writer.sampleValue(2, value));
91 BOOST_REQUIRE_EQUAL(value, SAMPLE3);
92 BOOST_REQUIRE(ns_writer.sampleValue(3, value));
93 BOOST_REQUIRE_EQUAL(value, SAMPLE4);
94 BOOST_REQUIRE(! ns_writer.sampleValue(4, value));
95 BOOST_REQUIRE(! ns_writer.sampleValue(101, value));
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));