blob: 47c0a4f273b873da4126824e46b05c42af7fc271 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "garnet/lib/callback/set_when_called.h"
#include <gtest/gtest.h>
namespace callback {
namespace {
TEST(SetWhenCalled, SetsTheInitialValueToFalse) {
bool called = true;
auto callback = SetWhenCalled(&called);
EXPECT_FALSE(called);
}
TEST(SetWhenCalled, SetsTheValueToTrueWhenCalled) {
bool called = false;
auto callback = SetWhenCalled(&called);
EXPECT_FALSE(called);
callback();
EXPECT_TRUE(called);
}
} // namespace
} // namespace callback