Skip to content

Commit cf977a0

Browse files
authored
Update memory leak test to include add_listener (#57)
1 parent d5dd03c commit cf977a0

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Source/Windows.Test/Threading/CancellationMemoryLeakTest.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
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>
@@ -22,6 +26,12 @@
2226
int 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
{

0 commit comments

Comments
 (0)