Remove InlineExecutor.cpp
[folly.git] / folly / test / CallOnceTest.cpp
index 843fa481978b332128d2296b1878c375109eab37..e0dccd81f87684fa84c2eea81994bac7d49f1eae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -50,6 +50,23 @@ TEST(FollyCallOnce, Simple) {
   ASSERT_EQ(1, out);
 }
 
+TEST(FollyCallOnce, Exception) {
+  struct ExpectedException {};
+  folly::once_flag flag;
+  size_t numCalls = 0;
+  EXPECT_THROW(
+      folly::call_once(
+          flag,
+          [&] {
+            ++numCalls;
+            throw ExpectedException();
+          }),
+      ExpectedException);
+  EXPECT_EQ(1, numCalls);
+  folly::call_once(flag, [&] { ++numCalls; });
+  EXPECT_EQ(2, numCalls);
+}
+
 TEST(FollyCallOnce, Stress) {
   for (int i = 0; i < 100; ++i) {
     folly::once_flag flag;