From 9d877e55b3ea987768f11c4840fc382075e9e00e Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 10 Aug 2020 16:28:05 +0100 Subject: [PATCH] add test for when scope exit lambda is an lvalue --- lib/test/adt/scope_exit_test.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/test/adt/scope_exit_test.cc b/lib/test/adt/scope_exit_test.cc index d91a4f87c..05dff6f18 100644 --- a/lib/test/adt/scope_exit_test.cc +++ b/lib/test/adt/scope_exit_test.cc @@ -61,6 +61,14 @@ int test_scope_exit(int* value) } TESTASSERT(nof_calls == 1); + // TEST: lvalue callback is safe + { + nof_calls = 0; + auto task = [&nof_calls]() { nof_calls += 2; }; + auto scope_exit = srslte::make_scope_exit(task); + } + TESTASSERT(nof_calls == 2); + return SRSLTE_SUCCESS; }