brpc/test/cancellation_flag_unittest.cc
2022-12-14 20:13:26 +08:00

37 lines
803 B
C++

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests of CancellationFlag class.
#include "butil/synchronization/cancellation_flag.h"
#include "butil/logging.h"
#include "butil/synchronization/spin_wait.h"
#include "butil/time/time.h"
#include <gtest/gtest.h>
namespace butil {
namespace {
TEST(CancellationFlagTest, SimpleSingleThreadedTest) {
CancellationFlag flag;
ASSERT_FALSE(flag.IsSet());
flag.Set();
ASSERT_TRUE(flag.IsSet());
}
TEST(CancellationFlagTest, DoubleSetTest) {
CancellationFlag flag;
ASSERT_FALSE(flag.IsSet());
flag.Set();
ASSERT_TRUE(flag.IsSet());
flag.Set();
ASSERT_TRUE(flag.IsSet());
}
} // namespace
} // namespace butil