MCPcopy Create free account
hub / github.com/DISTORTEC/distortos / phase2

Function phase2

test/Queue/QueueOperationsTestCase.cpp:330–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328 */
329
330bool phase2()
331{
332 for (const auto dynamic : falseTrue)
333 for (const auto raw : falseTrue)
334 for (const auto fifo : falseTrue)
335 {
336 const auto queueWrapper = makeQueueWrapper<1>(dynamic, raw, fifo);
337 const uint8_t constPriority {};
338 const OperationCountingType constTestValue {};
339 uint8_t nonConstPriority {};
340 OperationCountingType nonConstTestValue {};
341
342 {
343 // queue is not full, so tryPush(..., const T&) must succeed immediately
344 OperationCountingType::resetCounters();
345 waitForNextTick();
346 const auto start = TickClock::now();
347 const auto ret = queueWrapper->tryPush(constPriority, constTestValue); // 1 copy construction
348 if (ret != 0 || start != TickClock::now() ||
349 queueWrapper->checkCounters(0, 1, 0, 0, 0, 0, 0) != true)
350 return false;
351 }
352
353 {
354 const auto ret = testTryPushWhenFull(*queueWrapper);
355 if (ret != true)
356 return ret;
357 }
358
359 {
360 const auto ret = testTryPopWhenNotEmpty(*queueWrapper);
361 if (ret != true)
362 return ret;
363 }
364
365 {
366 const auto ret = testTryPopWhenEmpty(*queueWrapper);
367 if (ret != true)
368 return ret;
369 }
370
371 {
372 // queue is not full, so tryPush(..., T&&) must succeed immediately
373 OperationCountingType::resetCounters();
374 waitForNextTick();
375 const auto start = TickClock::now();
376 // 1 construction, 1 move construction, 1 destruction
377 const auto ret = queueWrapper->tryPush(constPriority, OperationCountingType{});
378 if (ret != 0 || start != TickClock::now() ||
379 queueWrapper->checkCounters(1, 0, 1, 1, 0, 0, 0) != true)
380 return false;
381 }
382
383 {
384 const auto ret = testTryPushWhenFull(*queueWrapper);
385 if (ret != true)
386 return ret;
387 }

Callers

nothing calls this directly

Calls 13

waitForNextTickFunction · 0.85
testTryPushWhenFullFunction · 0.85
testTryPopWhenNotEmptyFunction · 0.85
testTryPopWhenEmptyFunction · 0.85
tryPushMethod · 0.45
checkCountersMethod · 0.45
tryPushForMethod · 0.45
tryPopForMethod · 0.45
tryPushUntilMethod · 0.45
tryPopUntilMethod · 0.45
tryEmplaceMethod · 0.45
tryEmplaceForMethod · 0.45

Tested by

no test coverage detected