/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/EventBase.h>
-
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
namespace folly {
EXPECT_EQ(expected, value);
}
+TEST(AsyncTimeout, schedule_immediate) {
+ int value = 0;
+ int const expected = 10;
+ EventBase manager;
+
+ auto observer = AsyncTimeout::schedule(
+ std::chrono::milliseconds(0), manager, [&]() noexcept {
+ value = expected;
+ });
+
+ manager.loop();
+ EXPECT_EQ(expected, value);
+}
+
TEST(AsyncTimeout, cancel_make) {
int value = 0;
int const expected = 10;
EXPECT_NE(expected, value);
}
-} // namespace folly {
+} // namespace folly