8 #include "gtest/gtest.h"
14 using vec = std::vector<std::size_t>;
18 auto null_stream = std::unique_ptr<IJetStream>{
nullptr};
20 auto streamer = std::unique_ptr<JetStreamer> (
nullptr);
23 std::vector<std::size_t> jets0 {1, 2};
25 auto stream0 = std::make_unique<SimpleJetStream>(jets0,
26 std::move(null_stream),
29 streamer = std::make_unique<JetStreamer>(std::move(stream0));
32 }
else if (
test == 1) {
34 std::vector<std::size_t> jets_cs {5, 6, 7};
38 std::make_unique<CombinationsJetStream>(jets_cs,
39 std::move(null_stream),
43 streamer.reset(
new JetStreamer(std::move(stream0)));
45 }
else if (
test == 2) {
47 std::vector<std::size_t> jets0 {1, 2};
48 std::vector<std::size_t> jets1 {3, 4};
50 std::make_unique<SimpleJetStream>(jets1,
51 std::move(null_stream),
57 std::make_unique<SimpleJetStream>(jets0,
62 streamer.reset(
new JetStreamer(std::move(stream0)));
64 }
else if (
test == 3) {
66 std::vector<std::size_t> jets_cs {5, 6, 7};
68 std::vector<std::size_t> jets0 {1, 2};
73 std::make_unique<CombinationsJetStream>(jets_cs,
74 std::move(null_stream),
81 std::make_unique<SimpleJetStream>(jets0,
86 streamer.reset(
new JetStreamer(std::move(stream0)));
88 }
else if (
test == 4) {
90 std::vector<std::size_t> jets_cs {5, 6, 7};
92 std::vector<std::size_t> jets0 {1, 2};
96 std::make_unique<SimpleJetStream>(jets0,
97 std::move(null_stream),
103 std::make_unique<CombinationsJetStream>(jets_cs,
109 streamer.reset(
new JetStreamer(std::move(stream0)));
111 }
else if (
test == 5) {
114 std::vector<std::size_t> jets_cs {5, 6, 7};
116 std::vector<std::size_t> jets0 {1, 2};
117 std::vector<std::size_t> jets1 {3, 4};
120 std::make_unique<SimpleJetStream>(jets1,
121 std::move(null_stream),
126 std::make_unique<CombinationsJetStream>(jets_cs,
134 std::make_unique<SimpleJetStream>(jets0,
139 streamer.reset(
new JetStreamer(std::move(stream0)));
142 }
else if (
test == 6) {
145 std::vector<std::size_t> jets_cs {};
147 std::vector<std::size_t> jets0 {1, 2};
148 std::vector<std::size_t> jets1 {3, 4};
151 std::make_unique<SimpleJetStream>(jets1,
152 std::move(null_stream),
157 std::make_unique<CombinationsJetStream>(jets_cs,
165 std::make_unique<SimpleJetStream>(jets0,
170 streamer.reset(
new JetStreamer(std::move(stream0)));
173 }
else if (
test == 7) {
176 std::vector<std::size_t> jets_cs {5, 6, 7};
178 std::vector<std::size_t> jets0 {1, 2};
179 std::vector<std::size_t> jets1 {3, 4};
182 std::make_unique<SimpleJetStream>(jets1,
183 std::move(null_stream),
188 std::make_unique<CombinationsJetStream>(jets_cs,
196 std::make_unique<SimpleJetStream>(jets0,
201 streamer.reset(
new JetStreamer(std::move(stream0)));
204 }
else if (
test == 8) {
206 auto stream0 = std::unique_ptr<IJetStream>(
nullptr);
207 streamer.reset(
new JetStreamer(std::move(stream0)));
210 std::cerr <<
"unknown test << " <<
test <<
'\n';
215 TEST(JetStreamerTester, oneSimpleJetStream) {
218 EXPECT_EQ (
vec{1}, streamer->next());
219 EXPECT_EQ (
vec{2}, streamer->next());
220 EXPECT_EQ (
vec{}, streamer->next());
224 TEST(JetStreamerTester, oneCombinationsJetStream) {
230 EXPECT_EQ (
v0, streamer->next());
231 EXPECT_EQ (v1, streamer->next());
232 EXPECT_EQ (
v2, streamer->next());
233 EXPECT_EQ (
vec{}, streamer->next());
237 TEST(JetStreamerTester, twoSimpleJetStreams) {
245 EXPECT_EQ (
v0, streamer->next());
246 EXPECT_EQ (v1, streamer->next());
247 EXPECT_EQ (
v2, streamer->next());
248 EXPECT_EQ (v3, streamer->next());
249 EXPECT_EQ (
vec{}, streamer->next());
252 TEST(JetStreamerTester, SimpleThenCombinationsJetStreams) {
262 EXPECT_EQ (
v0, streamer->next());
263 EXPECT_EQ (v1, streamer->next());
264 EXPECT_EQ (
v2, streamer->next());
265 EXPECT_EQ (v3, streamer->next());
266 EXPECT_EQ (v4, streamer->next());
267 EXPECT_EQ (v5, streamer->next());
268 EXPECT_EQ (
vec{}, streamer->next());
271 TEST(JetStreamerTester, CombinationsThenSimpleJetStreams) {
281 EXPECT_EQ (
v0, streamer->next());
282 EXPECT_EQ (v1, streamer->next());
283 EXPECT_EQ (
v2, streamer->next());
284 EXPECT_EQ (v3, streamer->next());
285 EXPECT_EQ (v4, streamer->next());
286 EXPECT_EQ (v5, streamer->next());
287 EXPECT_EQ (
vec{}, streamer->next());
290 TEST(JetStreamerTester, SimmpleThenCombinationsThenSimpleJetStreams) {
306 EXPECT_EQ (
v0, streamer->next());
307 EXPECT_EQ (v1, streamer->next());
308 EXPECT_EQ (
v2, streamer->next());
309 EXPECT_EQ (v3, streamer->next());
310 EXPECT_EQ (v4, streamer->next());
311 EXPECT_EQ (v5, streamer->next());
312 EXPECT_EQ (v6, streamer->next());
313 EXPECT_EQ (v7, streamer->next());
314 EXPECT_EQ (v8, streamer->next());
315 EXPECT_EQ (v9, streamer->next());
316 EXPECT_EQ (v10, streamer->next());
317 EXPECT_EQ (v11, streamer->next());
318 EXPECT_EQ (
vec{}, streamer->next());
321 TEST(JetStreamerTester, InvalidJetIndices) {
324 EXPECT_EQ (
vec{}, streamer->next());
328 TEST(JetStreamerTester, InvalidNchooseK) {
331 EXPECT_EQ (
vec{}, streamer->next());
334 TEST(JetStreamerTester, InvalidJetStream) {
337 EXPECT_EQ (
vec{}, streamer->next());