6#include "gtest/gtest.h"
8TEST(ScopedCleanupClosureTest, DestructorDoesNothingWhenNoClosureSet) {
14TEST(ScopedCleanupClosureTest, ReleaseDoesNothingWhenNoClosureSet) {
18 EXPECT_EQ(
nullptr, cleanup.
Release());
21TEST(ScopedCleanupClosureTest, ClosureInvokedOnDestructorWhenSetInConstructor) {
27 EXPECT_FALSE(invoked);
33TEST(ScopedCleanupClosureTest, ClosureInvokedOnDestructorWhenSet) {
38 cleanup.
SetClosure([&invoked]() { invoked =
true; });
40 EXPECT_FALSE(invoked);
46TEST(ScopedCleanupClosureTest, ClosureNotInvokedWhenMoved) {
53 EXPECT_EQ(0, invoked);
56 EXPECT_EQ(1, invoked);
59TEST(ScopedCleanupClosureTest, ClosureNotInvokedWhenMovedViaAssignment) {
65 cleanup2 = std::move(cleanup);
67 EXPECT_EQ(0, invoked);
70 EXPECT_EQ(1, invoked);
Wraps a closure that is invoked in the destructor unless released by the caller.
fml::closure SetClosure(const fml::closure &closure)
TEST(ScopedCleanupClosureTest, DestructorDoesNothingWhenNoClosureSet)
#define EXPECT_TRUE(handle)