cancellation_flag_unittest.cc 803 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // Tests of CancellationFlag class.
  5. #include "butil/synchronization/cancellation_flag.h"
  6. #include "butil/logging.h"
  7. #include "butil/synchronization/spin_wait.h"
  8. #include "butil/time/time.h"
  9. #include <gtest/gtest.h>
  10. namespace butil {
  11. namespace {
  12. TEST(CancellationFlagTest, SimpleSingleThreadedTest) {
  13. CancellationFlag flag;
  14. ASSERT_FALSE(flag.IsSet());
  15. flag.Set();
  16. ASSERT_TRUE(flag.IsSet());
  17. }
  18. TEST(CancellationFlagTest, DoubleSetTest) {
  19. CancellationFlag flag;
  20. ASSERT_FALSE(flag.IsSet());
  21. flag.Set();
  22. ASSERT_TRUE(flag.IsSet());
  23. flag.Set();
  24. ASSERT_TRUE(flag.IsSet());
  25. }
  26. } // namespace
  27. } // namespace butil