File tree Expand file tree Collapse file tree
Source/Windows.Test/Threading Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010//
1111// Including cancellation.h brings the no_destroy inline variable definition into
1212// this translation unit, so it is constructed during static initialization before
13- // main runs. We call _CrtDumpMemoryLeaks explicitly and return a non-zero exit
14- // code so that CTest treats the test as failed when leaks are detected.
13+ // main runs. We also explicitly call add_listener on the none() token to verify
14+ // that the early-out path (which returns a dummy ticket) does not trigger any
15+ // heap allocations that would be reported as leaks.
16+ //
17+ // We call _CrtDumpMemoryLeaks explicitly and return a non-zero exit code so that
18+ // CTest treats the test as failed when leaks are detected.
1519
1620#include < crtdbg.h>
1721#include < cstdlib>
2226int main ()
2327{
2428#ifdef _DEBUG
29+ // Exercise the add_listener early-out path on cancellation::none().
30+ // This should not allocate any memory since none() returns a dummy ticket.
31+ {
32+ auto ticket = arcana::cancellation::none ().add_listener ([] {});
33+ }
34+
2535 // _CrtDumpMemoryLeaks reports all CRT debug-heap blocks still allocated.
2636 if (_CrtDumpMemoryLeaks ())
2737 {
You can’t perform that action at this time.
0 commit comments