diff --git a/Source/Windows.Test/Threading/CancellationMemoryLeakTest.cpp b/Source/Windows.Test/Threading/CancellationMemoryLeakTest.cpp index b6231df..937e733 100644 --- a/Source/Windows.Test/Threading/CancellationMemoryLeakTest.cpp +++ b/Source/Windows.Test/Threading/CancellationMemoryLeakTest.cpp @@ -10,8 +10,12 @@ // // Including cancellation.h brings the no_destroy inline variable definition into // this translation unit, so it is constructed during static initialization before -// main runs. We call _CrtDumpMemoryLeaks explicitly and return a non-zero exit -// code so that CTest treats the test as failed when leaks are detected. +// main runs. We also explicitly call add_listener on the none() token to verify +// that the early-out path (which returns a dummy ticket) does not trigger any +// heap allocations that would be reported as leaks. +// +// We call _CrtDumpMemoryLeaks explicitly and return a non-zero exit code so that +// CTest treats the test as failed when leaks are detected. #include #include @@ -22,6 +26,12 @@ int main() { #ifdef _DEBUG + // Exercise the add_listener early-out path on cancellation::none(). + // This should not allocate any memory since none() returns a dummy ticket. + { + auto ticket = arcana::cancellation::none().add_listener([] {}); + } + // _CrtDumpMemoryLeaks reports all CRT debug-heap blocks still allocated. if (_CrtDumpMemoryLeaks()) {